-1

When I type this

var sectionIntro = document.getElementsByClassName("section");

I get a list of my HTML.

However, when I try to take the first item in the array:

var sectionIntro = document.getElementsByClassName("section")[0];

I get undefined.

What is happening?

My HTML:

<section class="section">

        <div id="box1">
            <p class="theQuote">" We ignited, now you spark "</p>
            <p class="theQuoteW">~ Alumni</p>
        </div>

    <div class="introduction">
        <div id="box2">                

            <h4 id="intro">Intro</h4>

I want to take the class="section" using:

var sectionIntro = document.getElementsByClassName("section");
Grant Miller
  • 27,532
  • 16
  • 147
  • 165

1 Answers1

0

so the answer to this problem is the placement of javascript script in the html. I placed the script in the head, it should be at the end of the body