JavaScript Reference/Javascript Methods/createAttribute

Материал из Web эксперт
Версия от 11:22, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"createAttribute()" 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 type="button" value="Add attribute to the table" onclick="function1();"> </body> </html>


     </source>
   
  


"createAttribute()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |document | +----------------+--------------------------------------------------------------+

     </source>
   
  


"createAttribute()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Creates an attribute node. It also works with user-defined XML elements, allowing for the creation of custom attributes.

Syntax:

document.createAttribute(param1)

Parameters:

   param1   Required; the name of the attribute.
   
     
     </source>