In this video, we will be converting a jQuery code to Vanilla Javascript. This code adds a hover effect to elements with the class white-card, where the element changes color when the mouse enters and leaves the element.
To convert this to Vanilla Javascript, we need to first select all of the elements with the class white-card. In jQuery, we can use the $ function to select elements, but in vanilla JavaScript, we can use the document.querySelectorAll function.
Now that we have a reference to all of the white-card elements, we can use a loop to iterate over each element and attach event listeners to them.
The code uses the forEach function to loop through each element, and the addEventListener function to attach an event listener for the mouseenter and mouseleave events. Inside the event listener functions, we use the classList property to add and remove the is-blue class from the element.
#shorts