javascript - Jquery loading content via ajax -


i have unordered list used nav bar

<ul>             <li><a href="content/index.html" class="selected">home</a></li>             <li><a href="content/about.html" class="nav_bubble">about</a></li>             <li><a href="content/projects.html" class="nav_bubble">projects</a></li>             <li><a href="content/tutorials.html" class="nav_bubble">tutorials</a></li> </ul> 

and have javascript load content div

<script type="text/javascript">         $(function(){             $("div#navcontainer > ul > li > a").click(function(e){                 e.preventdefault();                 $.ajax({                     url: e.currenttarget.href,                     cache: false,                     datatype: "html",                     success: function(data) {                         console.log(data);                         $("#content").html(data);                     }                 });             });         });     </script> 

all of works, question is, happens when load page content folder has link in it? sends browser page instead of loading div. how can recursivly load links content div instead of sending user directly them?

change:

$("div#navcontainer > ul > li > a").click(function(e){ 

to:

$("div#navcontainer > ul > li > a, div#content a").live('click',function(e){ 

"attach handler event elements match current selector, , in future."


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -