Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML, custom element attribute, will work on all browsers?
- <div id="c" my-custom-attr="myValue" data-my-custom-attr="another-value">
- Content here
- </div>
- <script type="text/javascript">
- $att1 = $('#c').attr('my-custom-attr');
- $att2 = $('#c').attr('data-my-custom-attr');
- </script>
- <div id="c" data-my-custom-attr="another-value">
- Content here
- </div>
- <script type="text/javascript">
- // Both produce the same output //
- console.log($('#c').attr('data-my-custom-attr'));
- console.log($('#c').data('my-custom-attr'));
- </script>
Add Comment
Please, Sign In to add comment