因为用的少,总忘记,今天写一个仿qq投票的功能,用到了,顺便做下备忘
[img]http://dl.iteye.com/upload/attachment/216587/8c9dd95b-0ff1-32b0-8a45-c7425a632ae9.jpg[/img]
1. 注意要try catch,用来兼容firefox和ie
2. 另外把select置空使用xx.length = 0即可,不用remove()
更多的见:
[url]http://www.w3school.com.cn/htmldom/dom_obj_select.asp[/url]
[img]http://dl.iteye.com/upload/attachment/216587/8c9dd95b-0ff1-32b0-8a45-c7425a632ae9.jpg[/img]
1. 注意要try catch,用来兼容firefox和ie
2. 另外把select置空使用xx.length = 0即可,不用remove()
function resetOption(){
var zdxjx = document.getElementById("zdxjx");
var xxmcs = document.getElementsByName("xxmc");
zdxjx.length = 0;
for(var i=1; i <= xxmcs.length; i++){
var option = document.createElement('option');
option.text = "最多选"+ i +"项";
option.value = i;
try{
zdxjx.add(option,null); // standards compliant
} catch(ex) {
zdxjx.add(option); // IE only
}
}
}
更多的见:
[url]http://www.w3school.com.cn/htmldom/dom_obj_select.asp[/url]