jquery can't get data attribute value

后端 未结 6 774
Happy的楠姐
Happy的楠姐 2020-12-01 04:28

I am trying to set a variable in jQuery. The value is supposed to be set on the click event of the button. The onclick event fires but the x10Device variable remains u

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 04:44

    You can change the selector 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/

提交回复
热议问题