Read from this blog, http://www.html5rocks.com/en/tutorials/webcomponents/template/, on how to use and access the template tag contents.
Also the script tag with type as text/template works the same way:
By setting the type to "text/template", it's not a script that the browser can understand, and so the browser will simply ignore it. This allows you to put anything in there, which can then be extracted later and used by a templating library to generate HTML snippets.
<!doctype html>
<head>
<head>
<script>
window.onload=function(){
document.getElementById('targetDiv').innerHTML = document.getElementById('hiddenTemplate').textContent;
};
</script>
</head>
<body>
<script id="hiddenTemplate" type="text/template"></script>
<div id="targetDiv"></div>
</body>
</html>
No comments:
Post a Comment