Can someone let me know what is the difference between this
and jQuery(this)
? I found that my code works if I use 'this
' and if I use jQuery(this)
it does not work. Does jQuery(this
) not query for the current object and return it?
I want to know the index of the image being clicked ( I now we have the index() method, but still want it through the below logic) Here is the full code:(edited as per request)
for(i=0;i<5;i++)
{
jQuery("#div1").append("<img src='slider.jpg'>");
}
imgArr=jQuery("#div1>img");
jQuery("#div1>img").click(display);
function display()
{
for(i=0;i<imgArr.length;i++)
{
if(this==imgArr[i])
{
alert(i);
}
}
}
Here if I replace this
with jQuery(this)
it does not work.