首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

依据select option text值自动选中下拉框

2013-08-26 
根据select option text值自动选中下拉框方法一:var selectOptionText Baz$(#select-1).find(opti

根据select option text值自动选中下拉框

方法一:

var selectOptionText = "Baz";
$("#select-1").find("option").filter(function(index) {
??? return selectOptionText === $(this).text();
}).attr("selected", "selected");

?

方法二:

var selectOptionText = "wobble";
$("#select-2").find("option").filter(function(index) {
return selectOptionText === $(this).text();
}).prop("selected", "selected");

热点排行