Posted By

manolis on 05/02/12


Tagged

selector


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


JQuery Compare Selectors


 / Published in: jQuery
 

Selectors are ARRAYs ... so you should do something like this $('div.a')[0] == $('div#a')[0]

or use the bellow method

  1. $.fn.isEqual = function($otherSet) {
  2. if (this === $otherSet) return true;
  3. if (this.length != $otherSet.length) return false;
  4. var ret = true;
  5. this.each(function(idx) {
  6. if (this !== $otherSet[idx]) {
  7. ret = false; return false;
  8. }
  9. });
  10. return ret;
  11. };
  12.  
  13. var a=$('#start > div:last-child');
  14. var b=$('#start > div.live')[0];
  15.  
  16. console.log($(b).isEqual(a));

Report this snippet  

You need to login to post a comment.