Compare Objects in jQuery/javascript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.