The isDefaultNamespace()
method returns true
if the specified namespace is default, otherwise false.
isDefaultNamespace |
Yes | 9.0 | Yes | Yes | Yes |
node.isDefaultNamespace(namespaceURI)
Parameter | Type | Description |
---|---|---|
namespaceURI | String | Required. The URI of the namespace to check |
It returns a Boolean type.
true
if the namespace is default, otherwise false
.
The following code shows how to check if the defined namespace is the default namespace.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction()<!-- w w w . j ava 2s . co m-->
{
var d=document.documentElement;
console.log(d.isDefaultNamespace("http://www.w3.org/1999/xhtml"));
}
</script>
</body>
</html>
The code above is rendered as follows: