How do I get the change event for a datalist?

前端 未结 6 696
轮回少年
轮回少年 2021-02-05 11:14

I am using a datalist and need to detect when the user selects something from the drop-down list. A similar question has been asked BUT I need it so that the event fires ONLY wh

6条回答
  •  情话喂你
    2021-02-05 12:00

    You can manually check it on change. But you need to check change of the input of datalist.

    $(document).on('change', 'input', function(){
        var options = $('datalist')[0].options;
        var val = $(this).val();
        for (var i=0;i

    FIDDLE

提交回复
热议问题