jQuery“ keyup”在移动设备上不起作用

时间:2018-09-26 04:00:49

标签: javascript android jquery keyup

我已经编写了这段代码来搜索产品中的woocommerce wordpress插件。

//product filter
jQuery(document).on("keyup",".pstext",function(){
    jQuery(".nopro").remove();
    var searchterm  = jQuery(".pstext").val();
    if(searchterm === ""){
        jQuery(".main-flavour").show();
        return;
    }
    jQuery(".main-flavour").hide();
    var curr_item = "";
    var found = 0;
    jQuery(".main-flavour").each(function(){
        curr_item = jQuery(this).children("input").attr("id").replace("-"," ");
        if(curr_item.indexOf(searchterm) != -1){
            found = 1;
            jQuery(this).show();
        }

    });
    if(found === 0 && jQuery('.addon-description').find('p.nopro').length === 0){
        jQuery(".addon-description").append("<p class='nopro'>No Products Found.</p>");
    }
});

此代码在台式机上可以正常运行,但在移动设备上无法正常运行。

你们能帮助我为移动设备解析此代码吗?

1 个答案:

答案 0 :(得分:0)

找到解决方案了:)

在此处发布解决方案,如果这可以帮助其他面临相同问题的人。

在我的情况下,默认情况下,我在移动设备上的搜索框中键入任何内容时,它会在大写字母中键入第一个字母,并且当我将大小写更改为小写时,它开始在我的移动设备上运行。

希望这会有所帮助。