Latest web development tutorials

XML DOM hasAttributeNS () method

Element Object Reference Element object

Definition and Usage

It returns TRUE if hasAttributeNS () method has the namespace and name match the specified attribute in the current element node, otherwise it returns FALSE.

grammar

hasAttributeNS(ns,name)

参数 描述
ns 必需。规定要查找的属性的命名空间。
name 必需。规定要查找的属性的名称。


Examples

The following code fragment uses loadXMLDoc () to " books_ns.xml " into xmlDoc, and check the first <title> element has specified whether the namespace and name properties:

Examples

xmlDoc=loadXMLDoc("books_ns.xml");

x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3cschool.cc/children/";

document.write(x.hasAttributeNS(ns,"lang"));

Output:

true

try it"

Element Object Reference Element object