Esempi Traversing "risalire il DOM"

 

Evidenzia:

 

 

 

Codice:

 

function test_parent () {
$("#menu, #menu *").css("background-color",""); //reset dello sfondo
$("#inizio").parent("ul").css("background-color","yellow");
}

function test_parents () {
$("#menu, #menu *").css("background-color",""); //reset dello sfondo
$("#inizio").parents("ul").css("background-color","yellow");
}

function test_closest () {
$("#menu, #menu *").css("background-color",""); //reset dello sfondo
$("#inizio").closest("li").css("background-color","yellow");
}