0

我正在尝试在一个站点上运行这两个单独的脚本。这是他们的样子:

<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;是导致问题的第二个脚本的底部。

4

1 回答 1

0

尝试在您的点击处理程序中添加一个 evt 参数,然后调用

evt.preventDefault();

这是对差异的很好描述:http: //fuelyourcoding.com/jquery-events-stop-misusing-return-false/

于 2011-03-29T12:25:41.523 回答