IE8 select element change event

Using jQuery attr or prop change value of select element.

e.g

$('#SID[option = value]').attr('selected', 'selected'); // $('#SID[option = value]').prop('selected', true);

This code will trigger change event in IE8, and not in FF, IE9.

So to fixed this, using these codes instead:

$('#SID').prop('disabled', true);
$('#SID[option = value]').attr('selected', 'selected'); // $('#SID[option = value]').prop('selected', true);
$('#SID').prop('disabled', false); //avoid change event triggered.
此条目发表在 html, javascript, 实验室 分类目录,贴了 标签。将固定链接加入收藏夹。