var value="***";
$("select").children("option").each(function(){
var temp_value = $(this).val();
if(temp_value == value){
$(this).attr("selected","selected");
}
});或者如下 $("select option[value='"+value+"']").attr("selected", "selected");
本文介绍了一种使用jQuery简化DOM操作的方法,通过两种不同的方式实现为下拉菜单的选项设置默认选中状态的功能。这两种方法都利用了jQuery强大的选择器能力和简洁的语法。
391

被折叠的 条评论
为什么被折叠?



