omg omg - 2 months ago 7
jQuery Question

How to catch the event of change of <select > with jQuery?

<select id="target">
<option value="1">item1</option>
<option value="2">item2</option>
<option value="3">item3</option>
</select>


Say,I want to do some processing according to selected value.

Answer
$('#target').change( function() {
   $(this).find(":selected").each(function () {
            console.log( $(this).val() );
    });
 });
Comments