当< option>被添加或从< select>中删除时,jquery事件 [英] jquery event for when <option>s are added or removed from a <select>
本文介绍了当< option>被添加或从< select>中删除时,jquery事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一个jquery事件,当选项被添加或从HTML页面上的选择控件删除?我试过 .change()
,但是当我点击选项元素时,它似乎只是起火。即这不工作:
Is there a jquery event for when options are added or removed from a select control on an HTML page? I have tried .change()
but it only seems to fire when I click on option elements. I.e. this doesn't work:
$(function() {
$('#select').change(function() {
alert('hello world');
})
});
谢谢:)。
推荐答案
您需要一个插件来检查是否添加了HTML或从DOM中删除了HTML。 livequery是一个插件 http://docs.jquery.com/Plugins/livequery
You need a plugin to check if there is HTML added or removed from the DOM. livequery is a plugin http://docs.jquery.com/Plugins/livequery
这篇关于当< option>被添加或从< select>中删除时,jquery事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文