data- attribute in a click event?
I have a button defined like this:
<input type="button" class="add-fav-button" data-location="Canada" />
So then I have a click event in which I want to read in that data value
document).ready(function () {
$(".add-fav-button").click(function () {
var location = $(this).data("location");
});
});
...but the data item evaluates to "undefined"
Am I doing this wrong?
Thanks,
Steve