I'm learning the use of Data-* attribute in HTML5 and JQuery, about How to retrieve data simply from a div.
This is my markup:
<!DOCTYPE html>
<html >
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(function () {
$('#restoreButton').click(function () {
var sources$ = $('div').data('module');
});
});
</script>
<div data-module="Sources" data-module-id="sourcePane">
<button type="button" class="green90x24" id="restoreButton">Restore</button>
</div>
</body>
</html>
It says the variable sources$ is Undefined
.
I am using simple data() function of JQuery, but doesn't work. I've seen this is one of the Basic.
Any suggestion would be helpful