How to find the parent element

Once we have a reference to an HTML element, sometimes we need to know what element contains it. We can get this information from the DOM tree by asking for the element's parent.

var pid = $("#mytarget").parent().attr("id");