Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script> <script> $(document).ready(function () { $('#btnShow').click(function(){ alert('Parent element of #inrDiv: ' + $('#inrDiv').parent().html()); }); }); </script> </head> <body> <h1>Demo: jQuery parent() method</h1> <button id="btnShow">Show parent</button> <div> <p>This is First paragraph.</p> </div> <div id="myDiv"> <p> This is second paragraph. </p> <div id="inrDiv"> <p>This is third paragraph.</p> </div> <div> <ul> <li>First</li> <li>Second</li> <li>Third</li> </ul> </div> </div> <div> <p>This is fourth paragraph.</p> </div> </body> </html>
Result: