Selecting value of active select with jQuery -
in viw have 5-15 dynamically created dropdowns this:
<select class="task-type" id="21"> <option value=""></option> <option value="easy">easy</option> <option value="hard">hard</option> </select>
where class task-type
used every dropdown , id
unique each every , represents record in database, vary 1 10000.
i have following jquery code try pick value of dropdown has changed value:
$( '.task-type-select' ).change(function(){ alert($( ".task-type-select option:selected" ).text()); });
however, alerts every dropdown's value, need changed one.
any or guidance appreciated.
you can use this
keyword reference element raised event. there can use val()
method selected value:
$('.task-type-select').change(function(){ console.log($(this).val()); });
Comments
Post a Comment