0

I have written this code to search a product for woocommerce wordpress plugin.

//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>");
    }
});

This code is working fine on desktop but not working on mobile device.

Can you guys help me resolve this code for mobile devices.

rrk
  • 15,677
  • 4
  • 29
  • 45
Suresh Patel
  • 15
  • 1
  • 8
  • 1
    Possible duplicate of [jQuery: keyup event for mobile device](https://stackoverflow.com/questions/38989559/jquery-keyup-event-for-mobile-device) – Azad Sep 26 '18 at 04:02

1 Answers1

0

Got the solution :)

Posting the solution here, if that could help anyone else who are facing the same problem.

In my case when i was typing anything in search box on mobile device by default it type first alphabet in capital letter and when i have change the case to lowercase it started working on my mobile device.

Hope this will help.

Suresh Patel
  • 15
  • 1
  • 8