Skip to content

Instantly share code, notes, and snippets.

@ambar
Created August 25, 2011 08:42
Show Gist options
  • Save ambar/1170249 to your computer and use it in GitHub Desktop.
Save ambar/1170249 to your computer and use it in GitHub Desktop.
jQuery data compatibility
<html>
<head>
<title></title>
</head>
<body>
<div data-ID="3" data-blogId="4" data-comment-id="4" data-cat_id="5"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(function() {
var d = $('div').data();
// $.fn.jquery
console.log( JSON.stringify(d) );
})
/*
1.6.2
chrome 12 : {"id":3,"blogid":4,"commentId":4,"cat_id":5}
firefox 6 : {"cat_id":5,"commentId":4,"blogid":4,"id":3}
ie 9 : {"cat_id":5,"commentId":4,"ID":3}
*/
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment