I am reading an excellent book about jQuery (Apress Pro jQuery) and I am a little confused about the use of ‘this’.
For example I am reading the following code :
<script type="text/javascript">
$(document).ready(function() {
var isResult = $('img').is(function(index) {
return this.getAttribute("src") == "rose.png";
});
console.log("Result: " + isResult);
});
</script>
I am wondering at which object in this case ‘this’ refers to.
Thank you.
thisin the “this” context is a reference to the DOMimgelement.