JavaScript Reference/Javascript Methods/getAttribute

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

"getAttribute()" Example

   <source lang="javascript">
   

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

   var m = document.getElementById("myDiv").getAttribute("id");
   alert(m);

} </script>

This is a div element

<input type="button" value="Get id attribute value" onclick="function1();"> </body> </html>


     </source>
   
  


"getAttribute()" is applied to

   <source lang="javascript">

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

| |
|

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

| |
|

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

| | | <dir> |

| |
|

| |

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

| |
<html> |

| | <iframe> | | |<img> <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>

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

        "getAttribute()" Syntax, Parameters and Note

        <source lang="javascript"> Note: Returns the attribute.

        Syntax:

        objectName.getAttribute(param1, param2) document.getElementById("elementID").getAttribute(param1, param2) document.all.elementID.getAttribute(param1, param2) // IE only Parameters: param1 Required; the attribute"s name.


        </source>

      <textarea> | | |<tfoot> |

      | |<thead> <title> |

      | |