We often need access of parent elements in the DOM while using jQuery functions.This can be achieved by using element.parent().
Let us take some example:
HTML Code:
jQuery Code:
Let us take some example:
HTML Code:
<div id="div1"> <span>This is span</span> </div>
jQuery Code:
<script> $($document).ready(function(){ var par_id = ("span").parent().attr('id'); alert(par_id); }); </script>
Comments
Post a Comment