JavaScript Reference/Javascript Properties/activeElement

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

"activeElement" Example

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



"activeElement" is applied to

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



"activeElement" Syntax and Note

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