A RetroSearch Logo

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

Search Query:

Showing content from https://webplatform.github.io/docs/dom/NamedNodeMap/setNamedItem below:

setNamedItem ยท WebPlatform Docs

setNamedItem Summary

Adds an attribute to an element by using an attributes collection.

Method of dom/NamedNodeMapdom/NamedNodeMap

Syntax
var object = object.setNamedItem();
Parameters ppNode
Data-type
any

attribute

Return Value

Returns an object of type DOM NodeDOM Node

IHTMLDOMAttribute

attribute

attribute

Examples

The following example shows how to add an attribute to an element using the setNamedItem method.

<html>
<head>
<title>setNamedItem example</title>
<script>
function fnSetNamedItem(){
var nnm = myDIV.attributes;
var namedItem = document.createAttribute("title");
namedItem.value = "This is a ToolTip";
nnm.setNamedItem(namedItem);
}
</script>
</head>
<body onload="fnSetNamedItem();">
<div id="myDIV">This DIV now has a ToolTip.</div>
</body>
</html>

View live example

Notes Remarks

An attribute that is set with this method does not have to apply to the element. If an attribute with the same name is already present, it is replaced by the new attribute. setNamedItem was introduced in Microsoft Internet Explorer 6.

Syntax Standards information 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