How to use DOM Object GetElementByTagNameNs in JavaScript

In this article I am going to explain about DOM Object GetElementByTagNameNS() Method in JavaScript.
  • 3842

JavaScript DOM Object GetElementByTagNameNS() Method

JavaScript getElementByTagNameNS() method use for return multiple element with particular tag name in document and with specified Namespace.

Syntax

document.getElementByTagName("Url name","Tag Name")

Example // In this example when you will click on button then button text will be display in text form.

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>

    <script type="text/javascript">

        function myfun() {

            var mm = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "button");

            var butText = mm[0].childNodes[0].nodeValue;

            document.getElementById("dmm").innerHTML = butText;

        };

    </script>

</head>

<body>

    <h3 id="dmm" style="color: Blue">

        click button for display button text</h3>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

Before Click button


ns1.gif

 

After click button


ns2.gif

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.