如何使用jQuery在选择框中预选选项 [英] How to preselect option in select box using jQuery
本文介绍了如何使用jQuery在选择框中预选选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当一个页面加载时,一个带有值的选项,例如10,应该用jQuery预选。
p>我该怎么做?
解决方案
(你可以把它放在< body onload =// put code here>
):
$( 选项[值= '10' ])ATTR( '选择', '选择');
I have one select box with various options.
When a page loads then one option with a value, for example 10, should be preselected with jQuery.
How can I do that?
解决方案
When the page loads run this (you can put it in <body onload="//put code here">
):
$("option[value='10']").attr('selected','selected');
这篇关于如何使用jQuery在选择框中预选选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文