Jquery与其他脚本的冲突问题

时间:2013-01-10 22:53:45

标签: jquery

你好,在我的网站上我运行了许多Jquery插件,比如carouFredSel,nivoslider,cloud-zom等......他们工作正常,直到我添加了这个jquery脚本:

<script type="text/javascript" src="jquery.lightbox_me.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    $(function() {
        function launch() {
             $('#sign_up').lightbox_me({centered: true, onLoad: function() { $('#sign_up').find('input:first').focus()}});
        }
        $('#try-1').click(function(e) {
            $("#sign_up").lightbox_me({centered: true, onLoad: function() {
                $("#sign_up").find("input:first").focus();
            }});
            e.preventDefault();
        });
        $('table tr:nth-child(even)').addClass('stripe');

            $(".sign_up2").lightbox_me({centered: true, onLoad: function() {
                $(".sign_up2").find("input:first").focus();
            }});
            e.preventDefault();

    });
</script>

添加此代码后,我的滑块停止工作,还有图像缩放...请做非冲突?

2 个答案:

答案 0 :(得分:1)

您有两种选择。使用jquery noconflict

http://api.jquery.com/jQuery.noConflict/

或者使用

限制对jquery的调用范围
(function($) {
    // code here
})(jquery)

答案 1 :(得分:0)

在我看来,您的代码中有一个孤立的e.preventDefault();。先清理一下。然后我们会看看你是否还有问题。

相关问题