JavaScript Reference/Javascript Methods/setAttributeNode

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

"setAttributeNode()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1() {

   var newAttr = document.createAttribute("width");
   newAttr.nodeValue = "400px"
   document.getElementById("myB").setAttributeNode(newAttr); 

} </script>

Expand this table This is another cell

<input id="myB" type="button" value="Add attribute to the table" onclick="function1();"> </body> </html>


     </source>
   
  


"setAttributeNode()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> | | |<base> <basefont> | | | <bgsound> |

| |
|

| |<body>
| | |<button> |

| |
|

| | <col> | | |<colgroup> <comment> | | |<custom>

| | | |

| |<dir>
| | |
| | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|

| |<html> | | |<iframe> <img> | | |<input> <input type="button"> | | |<input type="checkbox"> <input type="file"> | | |<input type="hidden"> <input type="image"> | | |<input type="password"> <input type="radio"> | | |<input type="reset"> <input type="submit"> | | |<input type="text"> | | |<isindex> | | |<label> <legend> |

| |
  • <link> | | |<listing> <map> | | |<marquee> <menu> | | |<meta> <nobr> | | |<noframes> <noscript> | | |<object>
      | | |<optgroup> <option> | | |

      <param> | | |<plaintext>

                               |
      |                |                                                       |
      |                |                                                     |
      |                |                          <script>                      |
      |                |<select>                                               |
      |                |                                                |
      |                |                        <style>                       |
      |                |style                                                    |
      |                |                                                  |
      |                |<tbody>                                                   |
      |                |                                                       |
      |                |
        | | | <xml> | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>

        "setAttributeNode()" Syntax, Parameters and Note

        <source lang="javascript"> Note: This method adds an attribute node to the element.

        Syntax:

        document.getElementById("elementID").setAttributeNode(param1) document.all.elementID.setAttributeNode(param1) // IE only Parameters: param1 Required; the name of the attribute to be added.


        </source>

      |

      | |<textarea> <tfoot> |

      | |
      <thead> | | |<title>