JQuery从属性的值中设置<select>索引

这个问题在这里已经有了答案:

  • 用jQuery 15个答案更改下拉列表的选定值

  • 尝试

    $('#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/83909.html

    上一篇: JQuery set <select> index from the value of attribute

    下一篇: How to set selected value in dropdown through javascript