当前位置: 代码迷 >> Web前端 >> 依据select option text值自动选中下拉框
  详细解决方案

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

热度:645   发布时间:2013-08-26 12:17:40.0
根据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");
  相关解决方案