Home >Web Front-end >JS Tutorial >Two good ways to obtain event sources in javascript event functions_javascript skills

Two good ways to obtain event sources in javascript event functions_javascript skills

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

Copy code The code is as follows:

text




Second:

Use the hidden event object directly. The event object has a srcElement attribute, which can be accessed directly
Copy code The code is as follows:

< ;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
Previous article:jquery parsing JSON data sample code_jqueryNext article:jquery parsing JSON data sample code_jquery

Related articles

See more