我想在一个网站上运行这两个单独的脚本。这是他们看起来如何:jQuery冲突 - .load和悬停意图
<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"
}, 1000);
});
});
$(this).addClass('active');
return false;
});
</script>
他们都单独工作,但不是在一起。它似乎是导致问题的第二个脚本底部的return false;
。
'返回false;'防止click事件从“流血”到页面中的其他元素,还可以防止发生正常的点击行为(如跟随链接或提交表单)。你真的需要那个'返回假';那里? – 2011-03-29 12:21:10
@理查德尼尔伊拉甘 - 谢谢。是的,如果不存在,页面会正常加载(没有Ajax效果)。 – Infocentre 2011-03-29 12:26:57
啊,那么你只是想停止点击从实际上跟随到链接。在下面检查@rcravens的答案;这应该适合你。 – 2011-03-29 12:28:42