A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Node/hasAttributes below:

hasAttributes · WebPlatform Docs

hasAttributes Summary

Returns whether this node (if it is an element) has any attributes

Method of dom/Nodedom/Node

Syntax
var bResult = object.hasAttributes();
Return Value

Returns an object of type BooleanBoolean

true if this node has any attributes, false otherwise.

Examples

The following example will display an alert message that "the root element has attributes’. No following alert is displayed for the body element as it has no attributes.

<!DOCTYPE html>
<html id="root" class="desktop">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>hasAttributesExample</title>
</head>

<body>
<script type="text/javascript">
var re=document.getElementById('root');
if(re.hasAttributes()){alert('the root element has attributes');}
var be=document.body;
if(be.hasAttributes()){alert('the body element has attributes');}
</script>
</body>

</html>
Notes Remarks

The hasAttributes method determines whether the object has any attributes at all. The hasAttribute method tests for the existence of a specified attribute.

Related specifications
DOM Level 2 Core
Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4