JQuery set <select> index from the value of attribute
This question already has an answer here:
Try
$('#owner_select').val(id);
http://jsfiddle.net/qWycT/
function select( id ) {
var select = $( '#owner_select' ),
option = select.find( 'option' );
option.each( function( index ) {
if( $( this ).val() == id ) {
$( this ).attr( 'selected', 'selected' );
}
});
select = null,
option = null;
}
链接地址: http://www.djcxy.com/p/83910.html