开发者

jQuery action whenever any select is changed

开发者 https://www.devze.com 2022-12-15 13:09 出处:网络
开发者_JS百科Using jQuery, how can I make it so that a function is called whenever any select object on the page is changed?You can bind the change event to all the select elements on the DOM:

开发者_JS百科Using jQuery, how can I make it so that a function is called whenever any select object on the page is changed?


You can bind the change event to all the select elements on the DOM:

$('select').change(function () {
  // do something
});

Inside the event handler, the this keyword refers to the select element triggered the event, and you can get it's attributes, eg. var selectId = this.id;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号