jQuery - parents()

The parents() method returns all ancestor elements of the selected element, all the way up to the document's root element (<html>).

Hello World

 


$("#btnDemo").click(function ()
{
    $("#demo2").parents().css({ "background-color": "yellow" });
});