JavaScript Reference/Javascript Methods/namedItem

Материал из Web эксперт
Перейти к: навигация, поиск

"namedItem()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
    document.all.namedItem("myDiv1").innerText = "Named Item"; 
} 
</script>
<div id="myDiv1" style="width:600; height:200; background-color:blue;">
Click button to change me
</div>
<button onclick="function1();">Named item</button>
</body>
</html>



"namedItem()" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |all*                            anchors*                      |
|                |applets*                        areas*                        |
|                |boundElements*                  cells*                        |
|                |elements*                       embeds*                       |
|                |filters*                        <form>                        |
|                |forms*                          frames*                       |
|                |images*                         imports*                      |
|                |links*                          options*                      |
|                |plugins*                        rows*                         |
|                |<select>                        scripts*                      |
|                |styleSheets*                    tBodies*                      |
+----------------+--------------------------------------------------------------+



"namedItem()" Syntax, Parameters and Note

Note:
Returns the named element from the collection or the named item from a 
<form> or <select> element.
    
Syntax:
    
collectionName.namedItem(param1)
document.getElementById("elementID").namedItem(param1)
document.all.elementID.namedItem(param1) // IE only
Parameters:
    param1   Required; the name or id of the element.