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>
HTML part:
2. Usage of this in jquery:
JS part:
<script type="text/javascript"> $(document).ready(function(){ alert(this.src); }) </script>
HTML part:
I hope this article will be helpful to everyone in JavaScript programming.