Javascript DOM How to - Change content using innerHTML with a non-standard element








Question

We would like to know how to change content using innerHTML with a non-standard element.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
document.createElement("testele");
window.onload = function() {<!--from   w  ww.  j  a  v  a  2 s . c  om-->
    document.getElementsByTagName("testele")[0].innerHTML = "hi";
};

</script>
</head>
<body>
  <testele>bye</testele>
</body>
</html>

The code above is rendered as follows: