'this' object in jQuery -


can let me know difference between this , jquery(this)? found code works if use 'this' , if use jquery(this) not work. jquery(this) not query current object , return it?

i want know index of image being clicked ( have index() method, still want through below logic) here full code:(edited 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 replace this jquery(this) not work.

i suppose "this" reference dom element in first example?

jquery(this) jquery wrapper around 1 or more dom elements. when compare dom element, never equal.

if want dom element jquery wrapper, use indexer first element:

jquery(this)[0] === 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -