Week 6 + Problem Set

Tutorials

Problem Set

<body>
    <p> svbukbshbyudwd ugwig dkjniouhw io niwdih</p>     //1
    <p> svbukbshbyudwd ugwig dkjniouhw io niwdih diwhdiwdhiddhwihd cscx </p>     //2
    <p> svbukbshbyudwd ugwig dkjniouhw io niwdih diwhdiwdhiddhwihd cscx </p>     //3
</body>

let pTag = document.querySelector("p");   // will return the first p tag
let PTags = document.querySelectorAll("p");  // will return all three p tags

There is a difference between querySelector() and querySelectorAll(). When you pass in a value for example a “p” tag, both selectors function differently. querySelector will return the first instances of the “p” tag whereas querySelecterAll will return all instances of “p” tags.

Leave a comment

Your email address will not be published. Required fields are marked *

css.php