JavaScript JavaScript and the DOM Responding to User Interaction Listening for Events with addEventListener()

HARMANDEEP PANNU
HARMANDEEP PANNU
7,092 Points

Can I make text uppercase using listItems.style.textTranform = 'uppercase';

listItems.addEventListener("mouseover", () => {
    listItems.style.textTransform = 'uppercase';
})

listItems.addEventListener("mouseout", () => {
    listItems.style.textTransform = "lowercase";
}) 

This is what I meant

1 Answer

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there! Yes, you can! And simultaneously, no. I'm assuming here that your listItems is a collection of list items inside either an ordered or unordered list. Remember, that eventListeners are only available on an individual element, not a collection of elements. So you would need to loop over the collection of list items and add the event listeners that way.

I made a Code Pen which does what I think you want to do. It grabs the collection of list items from the DOM and then iterates over them adding both event listeners to each list item.

Hope this helps! :sparkles: