homerun
homerun

Reputation: 20775

html custom new tag and get new tag content

i found my self in the past few days interesting in html custom tags so i decided to give it a shot , i haven't found a lot of information on the web but i got some results , i think.

here is the code i reached so far

<html>
   <body>

     <newtag>ds</newtag>

     <script type="text/javascript">
        var newtag = document.getElementsByTagName('newtag');
        alert(newtag.innerHTML);
     </script>

  </body>
</html>

the alert is giving me the value "undefined" ,

i don't really know if what i have done is good , and if the syntax to suppose to be write like this , and i don't know even if the html custom tag is possible

thank you.

Upvotes: 1

Views: 348

Answers (1)

Pointy
Pointy

Reputation: 414006

The "getElementsByTagName()" function returns a node list:

alert(newtag[0].innerHTML);

You can treat the node list as an array, though it's not really an instance of Array.

Upvotes: 1

Related Questions