Examples of this keyword usage in javascript and jquery,

Source: Internet
Author: User

Examples of this keyword usage in javascript and jquery,

This article analyzes the usage of the this keyword in javascript and jquery. We will share this with you for your reference. The details are as follows:

This indicates the current object. The current object can be a form, <p>, or any other element.

1. usage of this in javascript:

JS section:

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

HTML section:
Copy codeThe Code is as follows:

2. usage of this in jquery:

JS section:

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

HTML section:
Copy codeThe Code is as follows:

I hope this article will help you design JavaScript programs.

Articles you may be interested in:
  • Learn the this keyword of javascript
  • This keyword in JavaScript is illustrated.
  • This in JavaScript
  • Examples of this usage in js
  • Differences between $ this and $ (this) in jQuery)
  • This and $ (this) in jQuery)
  • Usage of this in jquery

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.