jQuery conflicting - .load and hover intent
I am trying to run these two seperate scripts on one site. This is how they look:
<script type="text/javascript">
$(document).ready(function() {
var name = "";
$(".home-roll-box").hover(function() {
name = $(this).attr("id");
$("#image-"+name).stop().show().animate({ opacity: 1 });
}, function() {
name = $(this).attr("id");
$("#image-"+name).stop().animate({ opacity: 0 });
});
});
</script>
<!--/Band Images-->
<!--Navigation-->
<script type="text/javascript">
$.ajaxSetup ({ cache: false });
$('ul.navigation li a').click(function() {
$('ul.navigation li.page_item.current_page_item').removeClass('current_page_item');
$('ul.navigation li.page_item a.active').removeClass('active');
$('#content-wrap').animate({
top: "-2000px"
}, 1000 );
var targetPage = $(this).attr('href');
targetPage += " #content";
setTimeout(function() {
$('#content-wrap').load(targetPage, function() {
$('#content-wrap').animate({
top: "0px"
开发者_如何学Python}, 1000 );
});
});
$(this).addClass('active');
return false;
});
</script>
They both work individually, but not together. It seems to be the return false;
at the bottom of the second script that is causing the issues.
Try adding an evt parameter in your click handler and then calling
evt.preventDefault();
Here is a good description of the differences: http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/
精彩评论