JavaScript Reference/Javascript Properties/activeElement

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

"activeElement" Example

   <source lang="javascript">
   

<html> <body onLoad="myButton.focus();"> <input type="Button" id="myButton" value="Element 1" onClick="function1();"> <script language="JavaScript"> function function1() {

   var m = document.activeElement.value;
   alert("The active element is "+m); 

} </script> </body> </html>


     </source>
   
  


"activeElement" is applied to

   <source lang="javascript">

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

     </source>
   
  


"activeElement" Syntax and Note

   <source lang="javascript">

Note: Read-only property. Get the element that has focus, if the document is fully loaded.

Syntax:

document.activeElement


     </source>