I have this button:
<button type="button" class="themeChanger" data-themeValue="grid" value="Grid">
<img src="templateImages/Icon_200.png" />
</button>
And this jQuery:
$(".themeChanger").click(function () {
alert($(this).attr("data-themeValue"));
alert($(this).data("themeValue"));
});
For some reason the first alert shows “grid” like it should, but the second shows undefined. Is there something stupid I’m missing?
I think data will look on lowercases:
alert($(this).data("themevalue")) //gridor if you want to use themeValue you need to use:
edit:
I was wrong, it doesnt have anything to do with lowercases, you can use themeValue if you are having the attribute:
data-theme-valuethen you call itwith $(element).data(“themeValue”)