Two good ways to obtain event sources in javascript event functions_javascript skills
![WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB](/static/front/mobimages/moren/moren.png)
- WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
- 2016-05-16 16:55:221113browse
In JavaScript event response, in many cases we need to obtain the event source object to change its properties, such as changing the src attribute of img. There are two ways to obtain the event source in the event response function:
The first way:
Directly pass it in as a parameter. For example,
Second:
Use the hidden event object directly. The event object has a srcElement attribute, which can be accessed directly
< ;div id="myid" onclick="show();">text
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn