Change to a option on click? jQuery
I have a select inside a <开发者_StackOverflow社区tr>
. When you click on a link I would like the select change to the option that has value "00:00".
I tried myself and came this far:
jQuery(this).parents('tr').find('select')
How about this?
$(this).parents('tr').find('select').val('00:00');
$('#myLink').click(function(e){
$(this).closest('tr').find('option').val('00:00');
e.preventDefault();
});
As long as the <select>
has an <option ... value="00:00">...</option>
, .val()
will locate (and select) that <option>
for you.
Working Demo showing how .val()
finds the <option>
(and selects it) for you.
精彩评论