Using data attributes with jQuery

后端 未结 4 1923
我寻月下人不归
我寻月下人不归 2020-12-03 03:19

I have this button:

4条回答
  •  日久生厌
    2020-12-03 03:55

    I think it is the camel casing of hyphenated words in the data tag implementation that is the gotcha here

    Try this jsfiddle - http://jsfiddle.net/FloydPink/fb6Y6/

    
    
    
    
    $(".themeChanger").click(function () {
        alert($(this).attr("data-themeValue"));
        alert($(this).data("themeValue"));
    });
    

提交回复
热议问题