topical media & game development

talk show tell print

lib-jquery-learning-code-11-dom-traversal-jquery.grandparent.js / js



  // Step 1
  
  // jQuery.fn.grandparent = function() {
  //   var grandparents = [];
  //   this.each(function() {
  //     grandparents.push(this.parentNode.parentNode);
  //   });
  //   grandparents = jQuery.unique(grandparents);
  //   return this.setArray(grandparents);
  // };
  
  // Step 2
  
  jQuery.fn.grandparent = function() {
    var grandparents = [];
    this.each(function() {
      grandparents.push(this.parentNode.parentNode);
    });
    grandparents = jQuery.unique(grandparents);
    return this.pushStack(grandparents);
  };
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.