开发者

HTML select change event not called when selecting value of html select using jquery

In the be开发者_JAVA百科low code I am binding the change event to a HTML select and then trying to set its selected value. However, my change event is not called when I select the value of the HTML select via jQuery with the following code:

row.find(".js-sAttribute").change(function ()
{
    alert('1');
});

//**the following should trigger change event binded in the above code**
row.find(".js-sAttribute").each(function() { this.selected = (this.text == sAttEnum.ProductID); });

Please advise.


I believe what you need to do is call change() with no arguments after you change the selection manually. Otherwise, it won't actually trigger the change event...

row.find(".js-sAttribute").each(function() { 
   this.selected = (this.text == sAttEnum.ProductID);
   $(this).change(); 
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜