รหัสต่อไปนี้จะส่งกลับ 'ไม่ได้กำหนด' ...
$('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>
ควรใช้ $ (นี้) .find (': select') หรือ $ (this) .children ('ตัวเลือก: เลือก') หรือไม่
—
userBG
ดูคำถามนี้: stackoverflow.com/questions/648004/…
—
Jordan Brown