jQuery: get data attribute

后端 未结 5 2276
慢半拍i
慢半拍i 2020-11-27 03:18

In my html I have a span element:

This is a

5条回答
  •  渐次进展
    2020-11-27 03:59

    Change IDs and data attributes as you wish!

      
    
    $("#selectVehicle").change(function () {
         alert($(this).find(':selected').data("year"));
    });
    

    Here is the working example: https://jsfiddle.net/ed5axgvk/1/

提交回复
热议问题