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

Aakash Srivastav
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,616 Points

Listening for events with addEventListener()

This is my third question related to this video.
Now my question is , why doesn't he used the "style" property to make the letter uppercase, as he did in the other videos.
As he said , in order to change the css of any elements we use "style" property.
In this case it will go like this:

for( let i = 0 ; i < listItems.length ; i+=1){
    listItems[i].addEventListener( 'mouseover' , () => {

        listItems[i].style.textTransform = "uppercase";     // used "style" property      

    listItems[i].addEventListener( 'mouseout' , () => {

        listItems[i].style.textTransform= "uppercase";  // used "style property     

Is there any specific reason that he didn't used this method?

1 Answer

Daniel Hernandez
Daniel Hernandez
13,436 Points

I believe he used a different convention just to teach different ways of doing the same thing. I don't personally know the advantages over one method from the other, so I expect it is just a difference in method.