How do I get the change event for a datalist?

前端 未结 6 686
轮回少年
轮回少年 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 11:45

    More Optimize

    $("input").on('input', function () {
      if($('datalist').find('option[value="'+this.value+'"]')){
        //your code as per need
        alert(this.value);
      }
    });
    

提交回复
热议问题