Skip to main content

Posts

Showing posts from November 18, 2018

Get parent element in jQuery

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: <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>