Input List Selection Changed Event

一个人想着一个人 提交于 2019-11-30 08:57:33

The input event should work for what you need. As I understand, you can't use a datalist directly, but it is connected to an input by the list attribute. This event binding would go on that input:

document.getElementById('browsers-input').addEventListener('input', function () {
   console.log('changed'); 
});

http://jsfiddle.net/vccfv/

To get the same effect of "Explosion Pills" solution using JQuery style:

$("#browsers-input").on("input", MySuperFunction);

Usin jQuery you could use .change http://jquery.com/

$('datalist#browsers').change(MySuperFunction);

or

$('datalist#browsers').change(function(){
  // stuff
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!