转换Windows浏览器支持我的JQuery代码到iPhone Safari支持代码

时间:2017-07-23 10:57:45

标签: javascript jquery ios iphone safari

我的以下代码在Windows桌面浏览器中运行正常,但此代码在iPhone Safari浏览器中无效。

代码:

$(document).on("keydown", ".iselectinput", function(e) {
    if (e.keyCode == 8 && $(this).val() == '') {
        $(this).prev().find("li.ioption:last").remove();
    }
});

$(document).on('click', ".iselect .dropdown-menu a", function() {
    var loc1 = $(this).parent().prev().prev();
    var loc2 = $(this);
    var loc3 = loc1.find("li.ioption");
    var isInList2 = !!$(loc3).filter(function() {
        return $(this).text() == loc2.text();
    }).length;
    if (!isInList2) {
        loc1.append('<li class="ioption">' + $(this).text() + '<span class="iclosebtn"><i class="fa fa-times" aria-hidden="true"></i></span></li>');
        loc2.remove();
    }
});

如何将此代码转换为iPhone safari浏览器支持代码。我认为jQuery prev().filter无法在iPhone Safari浏览器中运行。

0 个答案:

没有答案
相关问题