开发者

Programmatically firing the onchange event of an HTML select element

How can I fire the onchange event of an HTML Select element by code.

The following only selects a list item but doesn't seem to fire the onchange event?

options[index].selected = t开发者_高级运维rue;


If the event is hoked up directly via onchange, you can invoke the handler by calling that handler, like this:

mySelect.options[index].selected = true;
mySelect.onchange();

...if it's not rigged up that way, then different approaches are appropriate depending on how you're binding, and more information about how your onchange handler(s) are attached would help.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜