Possible Duplicate:
What is the difference between $(this) and this
Anyone guide the difference of Jquery this
and $(this)
. Like in the below code I when I try to use $(this).id
does not work and if I use this.id
its working. I thought there is no difference between $(this)
and this
. I appreciate If someone explain the reason.
$(function($){
//This work
$('p').append( $('input').map(function(){
return this.id;
}).get().join(', '));
//This is not working? Could you explain what's the reason
$('p').append( $('input').map(function(){
return $(this).id;
}).get().join(', '));
});