Jquery Click Function Not Loading New Content
Solution 1:
get rid of + ' .main'
$("li a").live("click", function(){
$("#textoPequeno").load( $(this).attr('href') );
returnfalse;
});
is fine as long as there is content at 'href' to load into #textoPequeno
Solution 2:
Your code is fine, your html is wrong.
It looks like you're trying to create stand alone pages that also has the capabilities of being loaded through ajax.
You are appending ' .main'
to your .load()
call, which is equivalent to selecting '.main'
from the returned content. If you are doing that, all your html pages need to have an element with class='main'
in it.
My suggestion would be to use id='main'
instead of a class. Then change your call to: $("#textoPequeno").load($(this).attr('href')+' #main');
Solution 3:
rkw's answer is correct. I would add that you could also move the #main to the actual href prop. It may not seem like much, but it will reduce some overhead and in the event your AJAX call fails (Or for a few other reasons) the user is directed to the actual href - they would be sent to the correct spot.
Post a Comment for "Jquery Click Function Not Loading New Content"