Home > Web Front-end > JS Tutorial > Example analysis of this keyword usage in javascript and jquery_javascript skills

Example analysis of this keyword usage in javascript and jquery_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:23:52
Original
1517 people have browsed it

This article analyzes the usage of this keyword in javascript and jquery through examples. Share it with everyone for your reference, the details are as follows:

this represents the current object, which can be a form,

and other elements

1. Usage of this in javascript:

JS part:

<script type="text/javascript">
 function chimg(obj){
  obj.src="./images/2.jpg";
 }
</script>

Copy after login

HTML part:

Copy code The code is as follows:

2. Usage of this in jquery:

JS part:

<script type="text/javascript">
  $(document).ready(function(){
   alert(this.src);
  })
</script>

Copy after login

HTML part:

Copy code The code is as follows:

I hope this article will be helpful to everyone in JavaScript programming.

Related labels:
Statement of this Website
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template