jquery can't get data attribute value

后端 未结 6 772
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:55

    Make sure to check if the event related to the button click is not propagating to child elements as an icon tag ( Text $('button.toggleStatus').on('click', function (event) { event.preventDefault(); event.stopPropagation(); $(event.currentTarget).attr('data-X10'); });

提交回复
热议问题