JavaScript Reference/Javascript Methods/getElementById

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

"getElementById()" Example

   <source lang="javascript">
   

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

   var m = document.getElementById("myA");
   alert(m.innerText); 

} </script>

Click in the following element:

<a id="myA"

  href="http://www.wbex.ru" 
  onclick="return(false);" 
  onmouseup="function1();">Hyper link to wbex.ru

</a> </body> </html>


     </source>
   
  


"getElementById()" is applied to

   <source lang="javascript">

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

     </source>
   
  


"getElementById()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Get the element by id.

Syntax:

document.getElementById(param1) Parameters:

   param1   Required; the element"s id value.
   
     
     </source>