jQuery event when HTML5 Datalist option is clicked

前端 未结 3 1026
醉话见心
醉话见心 2020-12-15 18:50

What I have now:

So i have this HTML5 Datalist with a bunch of options in it, and I have 2 events firing. One when the user types out something that

相关标签:
3条回答
  • 2020-12-15 19:36

    To handle click only event here is the solution.

    $("#book_search").bind('select', function () {
        alert("changed");   
    });
    
    0 讨论(0)
  • 2020-12-15 19:37

    You can also listen to the 'select' event on the input field.

    $('#name').bind('select', function() {
        // handle input value change
    });
    
    0 讨论(0)
  • 2020-12-15 19:44

    Use the input event instead of the other events. It's actually designed to cover what you want:

    $("#name").bind('input', function () {
        window.checkModelData(this);
    });
    

    I made a jsfiddle for you to try it out.

    0 讨论(0)
提交回复
热议问题