jquery select set selectindex

To Read Select Option Value

$('#selectId').val(); 

To Set Select Option Value

$('#selectId').val('newValue'); 

To Read Selected Text

$('#selectId>option:selected').text(); 

 

 

// sets selected index of a select box to the option with the value "0" 
$
("select#elem").val('0');  
 
// sets selected index of a select box to the option with the value "" 
$
("select#elem").val('');  
 
// sets selected index to first item using the DOM 
$
("select#elem")[0].selectedIndex = 0; 

posted @ 2011-11-21 00:11  94cool  阅读(2934)  评论(0编辑  收藏  举报