jQuery库与函数冲突

时间:2012-08-24 11:00:21

标签: jquery

通过javascript使用动态菜单如下

<script type="text/javascript">


ddaccordion.init({`enter code here` //top level headers initialization
    headerclass: "expandable", //Shared CSS class name of headers group that are expandable
    contentclass: "categoryitems", //Shared CSS class name of contents group
    revealtype: "clickgo", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
    onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
    animatedefault: false, //Should contents open by default be animated into view?
    persiststate: true, //persist state of opened contents within browser session?
    toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["suffix", "<img src='<?php echo $this->baseurl; ?>/images/up.png' class='statusicon' />", "<img src='<?php echo $this->baseurl; ?>/images/down.png' class='statusicon'/>"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
        //do nothing
    },
    onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
        //do nothing
    }
})
</script>

使用ddaccordion.js库。当我将鼠标悬停在主菜单上时,我的子菜单会通过javascript弹出,如下所示

<script type="text/javascript">
jQuery.noConflict();
    var showQV = function(node) {
        node.fadeIn();
    };

    var hideQV = function(node) {
        node.fadeOut();
    };
    $(document).ready(function () {     
        var t1,t2;
        t1 = t2 = null;
        var currentQuickView = null;
        $(".popup_menu").hover(function() {


            clearTimeout(t2);
            var that = this;
            t1 = setTimeout(function() {
                currentQuickView && (currentQuickView.get(0) != $($(that).attr("popUpSelect")).get(0)) && hideQV(currentQuickView);
                currentQuickView = $($(that).attr("popUpSelect"));
                showQV($($(that).attr("popUpSelect")));
            }, 500);
        },
                function() {
                    var that = this;

                    clearTimeout(t1);
                    t2 = setTimeout(function() {
                        hideQV($($(that).attr("popUpSelect")));
                    }, 500);
                });

        $(".popUpView").hover(function() {
            clearTimeout(t2);
            var that = this;
            t1 = setTimeout(function() {
                showQV($(that));
            }, 500);
        },
                function() {
                    var that = this;
                    clearTimeout(t1);
                    t2 = setTimeout(function() {
                        hideQV($(that));
                    }, 500);
                });


        $(".jqVertTabs").click(function() {
            if (!$(this).hasClass("genTabOpen")) {
                var oldSelected = $(".genTabOpen");
                var newSelected = $(this);
                var oldTabId = parseInt(oldSelected.attr("tabId"));
                var newTabId = parseInt(newSelected.attr("tabId"));
                oldSelected.removeClass("genTabOpen").addClass("genTabClose");
                $(oldSelected.children()[0]).removeClass("tbOpen").addClass("tbClose");
                $(this).removeClass("genTabClose").addClass("genTabOpen");
                var child = $(this).children()[0];
                $(child).removeClass("tbClose").addClass("tbOpen");
                $(".arrowList", oldSelected.parent()).slideUp();
                $(".arrowList", newSelected.parent()).slideDown();

            }
        });
    });
</script>

使用main-menu.js。它完全适用于Firefox和IE。但铬的冲突。所以任何有用的解决方案对我都有帮助。

1 个答案:

答案 0 :(得分:0)

请勿致电jQuery.noConflict()。它删除$作为jQuery的快捷方式。您不需要 - $与其他任何内容都不冲突。首先加载jQuery,然后加载ddaccordion,然后加载自定义的jQuery代码。