<div id = "div1">
<div id = "div2">
<div id = "div3">
<div id = "div4">
</div>
</div>
</div>
</div>
<input type = "button" value = "Demo" id = "demo" />
<script type="text/javascript">
$("#demo").live("click", function () {
var div3 = $("#div4").parents("#div3");
var div2 = $("#div4").parents("#div2");
var div1 = $("#div4").parents("#div1");
});
</script>