The event in IE and the event in FF is not the same, access is not the same, such as IE in the event is the global Window object properties, and FF did not. There are a lot of times when we want to get the source object that triggers the event (srcelement in IE), here are two ways.
When writing JS, we have to consider the compatibility of IE and FF in many cases. Very simply, the event in IE and the event in FF are different
, such as IE, the event is the property of the global Window object, but the FF does not. There are a lot of times we want to get triggers
The source object of the event (srcelement in IE), the following two methods are given.
Passing an event parameter in a function
Passing the event argument in a function so that we can be compatible with IE and FF event acquisition, as in the following function:
function _test (EVT)
{
var src = evt.srcelement evt.target; Gets the source object that triggered the event
alert (Src.value); Print the Value property of this object
}
So we should do this when we use it:
<input type= ' button ' value= ' click me '/>
It can be seen that the second method is more general and universal than the two methods, since it is not possible to pass parameters, so that when used, it is more
Added convenience; The first way is more direct and clear, oh, as for the specific use, but also to look at the individual ~ ~