$(document).ready(function() { $("button").click(function() { var parentObj = $("#content a").parent(); console.log(parentObj[0]); // gets the p tag var childObj = $("#content").children(); console.log(childObj[0]); // gets the p tag var searchObj = $("#content").find("a"); console.log(searchObj[0]); // gets the a tag }); });
<h2>jCombat Demo - jQuery DOM Manipulations</h2> <div id="content"> <p>This is a paragraph. <a href="#">Sample Link</a></p> </div> <button>Click here</button>