Posted By

jonern on 02/20/11


Tagged

Objects compare comparison


Versions (?)

Compare Objects in jQuery/javascript


 / Published in: JavaScript
 

  1. $.fn.equals = function(compareTo) {
  2. if (!compareTo || !compareTo.length || this.length!=compareTo.length)
  3. {
  4. return false;
  5. }
  6. for (var i=0; i<this.length; i++) {
  7. if (this[i]!==compareTo[i]) {
  8. return false;
  9. }
  10. }
  11. return true;
  12. }
  13.  
  14. /* USAGE: element.equals(target);

Report this snippet  

You need to login to post a comment.