keydown event is not working for input type search in jquery mobile

允我心安 提交于 2019-12-07 18:12:27

From the docs found this: http://jquerymobile.com/test/docs/api/events.html

Important: Use $(document).on('pageinit'), not $(document).ready()

$(document).on( 'pageinit',function(event){
    $("#search1").keydown(function() {
        alert("keydown");           
        $("#search1").css("background-color", "yellow");
    });
    $("#search1").keyup(function() {
        alert("keyup");
        $("#search1").css("background-color", "pink");
    });
});

Tryout this and see if it helps.

Include jQuery Mobile file

What you need to do is just include a jQuery file into your project. A file named jQuery.mobile.js or quite similar (ex. jQuery.ui.js) of any version can help you.

You can download it from : jQuery Mobile Official | Download I suggest to use

ResolveClientUrl

while giving path.

Your code is working check here: JS Fiddle

FIDDLE'd

:)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!