我有一个由 ajax 填充的选择框。但是我需要使用 ajax 更改选择选项。以下代码在 IE 中有效,但在 Firefox 中无效。请帮忙。
var tts = $("select#myList option"); //collected all options
tts.each(function(i){
var cpid = this.attributes['pankti'].value; // check for desired rel tag
if(cpid === ppid) {
this.attr('selected','selected'); //...and select this option
}else{
this.removeAttr('selected',''); //.. else clear selection
}
});