当前第2页 返回上一页
(1)有时可能需要隐藏select,但是还得需要更改select所传递的值。(select的默认选中之为第一个,即下标为0的选项值)
1 2 3 4 5 6 | var gd2=document.getElementById( "goods_name2" );
if (gd2)
{
gd2[0].value=newvalue;
}
|
(2)原生js更改select选定的值
1 2 3 4 5 6 | var gd2=document.getElementById( "goods_name2" );
if (gd2)
{
gd2.value=newvalue;
}
|
1 2 3 | var obj = document.getElementById( "goods_name" );
var index = obj.selectedIndex;
obj.options[index].value=newvalue;
|
2、jquery设置select值的方法
1 2 | $( '#goods_name2 option:selected' ) .val(newvalue);
|
相关免费学习推荐:javascript视频教程
以上就是javascript如何设置select值的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
详解js中的垃圾回收和内存泄漏
javascript怎么将数字转换成时间
javascript中this用法有哪些
javascript如何设置焦点移除
浏览器启用javascript什么意思
javascript代码放哪
javascript使用什么标签实现
javascript数组如何求和
javascript中return的含义是什么
深入分析ajax的进度事件(附示例)
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » javascript如何设置select值