i am creating a javascript method which loads page contents inside a div container using jquery and it works properly, but when i click at any button inside the div itself, it redirects to new page?
that’s the method:
<script type="text/javascript">
$('a').click(function() {
var page = $(this).attr('href');
$("#content").fadeOut('slow', function(){
$("#content").load(page, function () {
$(this).fadeIn('slow');
});
});
return false;
});
</script>
anyone can solve this problem?
You are binding only element present on page loadnot ones created afterwards by using click if you use this instead it should work
Basically live will bind to all a tags even newly created ones.