新建 文本文档.txt

来自「can merge two datatable」· 文本 代码 · 共 39 行

TXT
39
字号
获取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 + =
减小字号Ctrl + -
显示快捷键?