daniel-plewinski
8/31/2017 - 1:02 PM

jQuery and JavaScript traversing poruszanie po DOM, DOM moving

jQuery and JavaScript traversing poruszanie po DOM, DOM moving

$("#demo").parent();                // accessing direct parent
$("span").parent().hide();          // changing parent color
$("#demo").parents();               // all ancestors of the element
$("#demo").parentsUntil("#demo2");  // all ancestors between two - demo is inside demo2
$("#demo").children();              // all direct children
$("#demo").children(".first");      // all direct children having a specified class
$("#demo").find("span");            // all span elements inside #demo
$("#demo").find("*");               // all descendants
$("#demo").siblings("span");        // span siblings of #demo
$("#demo").next();                  // the next sibling
$("p").nextAll();                   // all next siblings
$("#demo").nextUntil("#demo2");     // siblings between two arguments
$("#demo").prev();                  // the previous sibling
$("p").prevAll();                   // all previous siblings
$("#demo").prevUntil("#demo2");     // previous siblings between two arguments


// Javascript
barElement.parentElement;
bazElement.previousElementSibling;
bazElement.nextElementSibling;
allChildren = fooElement.children;
fooElement.firstElementChild;
bazElement.lastElementChild;