-
-
Save easierbycode/1787552 to your computer and use it in GitHub Desktop.
jQuery Private Data Should Stay Private
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<style> | |
article, aside, figure, footer, header, hgroup, | |
menu, nav, section { display: block; } | |
</style> | |
</head> | |
<body> | |
<p id="hello">Hello World</p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( function() { | |
var $hello = $( "#hello" ).click( function() { | |
alert( "hello world" ); | |
}); | |
// does NOT return object that includes the events property | |
console.log( $hello.data() ); | |
// does return events object | |
console.log( $hello.data( "events" ) ); | |
// does return object that includes the events property | |
console.log( $._data( $hello[ 0 ] ) ); | |
// does return evetns object | |
console.log( $._data( $hello[ 0 ], "events" ) ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment