1
給定一個下拉列表,是否有任何方法可以訂閱JavaScript,甚至在將新項目添加到列表時會觸發一個JavaScript?關於項目在下拉列表中添加事件(選項選擇器)
我想類似以下工作
$("select").itemAdded(function(value, text) {
alert(text + " has just been added to the list of options");
});
$("select").append($("<option></option").val("1").html("Something"));
//results in alert of "Something has just been added to the list of options"
不完全確定爲什麼有人認爲這應該是負面投票 - 我寫的東西沒有什麼錯,據我所知。 – Steerpike 2009-02-18 16:52:06