<select class='selb' id='selbauth' >
這個工程選擇選項:含有文本
$('#selbauth option[value="abc"]').attr('selected','selected');
相同,但按價值,而是由文本選擇不 - 不工作:
$('#selbauth option[text="lorem"]').attr('selected','selected');
我嘗試另一種方式:
function selbytext(dd, txt){
for (var i = 0; i < dd.options.length; i++) {
if (dd.options[i].text == txt) {
dd.selectedIndex = i;
break;
}
}}
selbytext($('#selbauth'), 'lorem');
錯誤:
Cannot read property 'length' of undefined
任何幫助?
它的作品,非常感謝。 – puerto
@puerto歡迎好友:) – Shiladitya