We would like to know how to set custom DOM element properties.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- w ww . j a va2s . c o m-->
var div = document.getElementById( 'test' );
div.dataset.baz = 'bar';
console.log( div.dataset.baz );
}
</script>
</head>
<body>
<div id="test"></div>
</body>
</html>
The code above is rendered as follows: