📄 01_select控件的动态options操作.txt
字号:
获取option被选的Value:
selectObj.options[selectObj.selectedIndex].value;
获取option被选的Text:
selectObj.options[selectObj.selectedIndex].text;
获取option被选的id序号:
selectObj.selectedIndex;
添加Option:
selectObj.options.add("text", "value");
修改Option:
selectObj.options[x].value = "value";
selectObj.options[x].text = "text";
删除Option:
selectObj.options[x] = null;
删除所有的Option:
selectObj.options.length = 0;
说明:
selectObj 为 select控件对象,可以通过:selectObj = document.getElementById(selectId) 来获取;
重点注意的:
option添加是: selectObj.options.add();
而selectObj.add(); 只能在IE下运行,不兼容Firefox;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -