Week 6-never give up

It has been a hard week but I did it!!!!

Tutorials

Problem Set

I chose ign because it looked like it would be easy and fun to give it a makeover. however, I did have a little changing something but overall its done

Blog Question


Describe how the querySelector() and querySelectorAll() methods work. What is the difference between the values returned for each method? Use an example code snippet to support your answer; include sample HTML and JS selectors.

querySelector() is taking the CSS Style selector and It returns the first element that matches a given CSS Style Selector.

<script>
function myFunction() {
  document.querySelector("p").style.backgroundColor = "red";
}
</script>

querySelectorAll() is returns all elements in the document that matches a specified CSS selector

<script>
function myFunction() {
  var x, i;
  x = document.querySelectorAll(".example");
  for (i = 0; i < x.length; i++) {
    x[i].style.backgroundColor = "red";
  }
}
</script>

Join the Conversation

1 Comment

  1. Hey I got your code to work once I got rid of all the returned console values. You should trim down your code to only your selectors and loops.

    document.querySelectorAll(".title")
    
    const titles = document.querySelectorAll(".title")
    
    titles[0].style.color = "red"
    
    for (i = 0; i < 5; i++){titles[i].style.color = "red"}
    
    for (i = 0; i < 5; i++){titles[i].style.textContent = "hahaahahahahahhahahahahahahahahahahahhahahaha"}
    
    for (i = 0; i < 5; i++){titles[i].style.textContent = "hahaahahahahahhahahahahahahahahahahahhahahaha"}
    
    
    for (i = 0; i < 5; i++){titles[i].textContent = "hahaahahahahahhahahahahahahahahahahahhahahaha"}
    
    for (i = 0; i < 5; i++){titles[i].textContent = "hahaaha"}
    
    document.querySelectorAll("h2")
    
    h2[0].style.color = "pink"
    
Leave a comment

Leave a Reply to admin Cancel reply

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

css.php