在下面的代码中,我将更改事件绑定到HTML选择,然后尝试设置其选定的值。但是,当我使用以下代码通过jQuery选择HTML select的值时,不会调用我的更改事件:
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); });
请告知。
答案 0 :(得分:1)
我相信您需要做的是在手动更改选择后调用不带参数的change()。否则,它实际上不会触发更改事件...
row.find(".js-sAttribute").each(function() {
this.selected = (this.text == sAttEnum.ProductID);
$(this).change();
});