JQuery下拉菜单<李>链接在Internet Explorer中不起作用

JQuery Dropdown Menu <li> Links Do Not Work In Internet Explorer

本文关键字:Explorer Internet 不起作用 gt 下拉菜单 lt JQuery 链接      更新时间:2023-09-26

我最近在这个开发人员的网站上实现了一个jQuery下拉列表:http://tympanus.net/codrops/2012/10/04/custom-drop-down-list-styling/,它在我的Chrome和Firefox网站上看起来和工作都很好(我的网站是:http://www.ExpeditionerSafaris.com)。

但是,在InternetExplorer中(当然),li链接不起作用。

这是代码:

function DropDown(el) {
    this.dd = el;
    this.initEvents();
}
DropDown.prototype = {
    initEvents: function () {
        var obj = this;
        obj.dd.on('click', function (event) {
            $(this).toggleClass('active');
            event.stopPropagation();
        });
    }
}
$(function () {
    var dd = new DropDown($('#dd'));
    $(document).click(function () {
        // all dropdowns
        $('.wrapper-dropdown-5').removeClass('active');
    });
});

我想你有jquery confliction参考的问题http://api.jquery.com/jQuery.noConflict/

代码有问题

$(function () {//here is problem of `$` conflictions
    var dd = new DropDown($('#dd'));
    $(document).click(function () {
        // all dropdowns
        $('.wrapper-dropdown-5').removeClass('active');
    });
});

我检查了它,代码有错误

Error: TypeError: $ is not a function
Source File: http://www.expeditionersafaris.com/
Line: 426

使用jQuery(function ()代替$(function (),然后尝试,或者使用jQuery.noConflict()函数

initEvents方法中。不要通过event,因为它与IE事件冲突,所以让它成为

obj.dd.on('click', function (evt) {
    //evt is jQuery normalized event object
    $(this).toggleClass('active');
    event.stopPropagation();
});