Instead of returning the body element Why my command document.firstElementChild.secondElementChild returns undefined?

<!DOCTYPE html>
	<title>2nd Code</title>
	<h1 class="heading">Lets Experiment in this Journey of Learning</h1>
		Hey <em><strong>Raj</strong></em> this is just the beginning of <strong>web devop</strong> <!-- The strong tag basically bold the letters present btw tags-->
		Yes this is also another paragraph <!--em converts simple to italic style-->
		<h1 class="details">My Details</h1>
		<ul id="List">
			<li class="name">Raj yadav</li>
			<li class="section details">ECE 2 Roll-79</li>
			<li class="college-details">Academy of Technology</li>
			<li><a href="" target="_blank">LinkedIn Profile</a></li>
		</ul><!--the target is used to open in the new tab not on the current-->
		<h3 id="best-college">The list of Few Best Colleges</h3>
			<li>Academy of technology</li>
			<li>MCKV Institute</li>
			<li>IIIT Hyderabad</li>

1 Like

secondElementChild is not a property, that’s why you get an error.

If you want to get the second one do this:

document.firstElementChild.children[1]; // remember indexes start at 0.

yes thanks for the response.
I found one another way also
document.firstElementChild.lastElementChild–> body
then you can further select within an body elment by doing first second and all

1 Like