The following code returns ‘undefined’…

$('select').change(function(){
    alert($(this).data('id'));
});

<select>
    <option data-id="1">one</option>
    <option data-id="2">two</option>
    <option data-id="3">three</option>
</select>

9 Answers
9

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *