JavaScript Reference/Javascript Properties/srcElement

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

"srcElement" Example

    
<html>
<body>
<script language="JavaScript">
    function function1() {
        alert(window.event.srcElement.id);
    }
</script>
<body id="myBody" onclick="function1();">
<button id="myButton1" onclick="function1();">Button One</button>
<button id="myButton2" onclick="function1();">Button Two</button>
</body>
</body>
</html>



"srcElement" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |event                                                         |
+----------------+--------------------------------------------------------------+



"srcElement" Syntax and Note

Note:
Read and write property. 
The object that fires the event.
    
Syntax:
    
window.event.srcElement = value