Reputation: 1683
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?
Upvotes: 2
Views: 973
Reputation:
You should use iframe instead. When you use a div like page, you just load content on it, not load page.
Upvotes: 0
Reputation: 10874
You are binding only element present on page loadnot ones created afterwards by using click if you use this instead it should work
$('a').live('click', function(){});
Basically live will bind to all a tags even newly created ones.
Upvotes: 2