How to make the Select Box Value selected to specific value "ABC" when new row is being added to table
I have a new row added to table with a buttton click and we have select element for each row and with name "code[]".I have to make the value "ABC" as selected when a new row is being added to the table
alert($('#mytabl tr:last :input').find('input[name="code[]"]').children($('option[value=ABC]')).attr('selected','开发者_如何转开发selected'));
with the above statement no Effect is being done
It seems like your selector is overly complicated, and not selecting a <select>
element, but looking for a <input>
inside a :input
currently, try this instead:
$('#mytabl tr:last select[name="code[]"]').val('ABC');
精彩评论