Skip to content

Instantly share code, notes, and snippets.

@toshimaru
Created October 15, 2013 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshimaru/6997737 to your computer and use it in GitHub Desktop.
Save toshimaru/6997737 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>data-attribute test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div id="tgt" data-msg='my message is here!'>
<p>Foo</p>
<p>Bar</p>
</div>
<script type="text/javascript">
$(function(){
$('#tgt').on('click', function(e) {
alert($(this).data('msg'));
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment