orzubalsky / creative-computing-2018

0 stars 1 forks source link

color changing js #110

Open Moniquezeitouny opened 6 years ago

Moniquezeitouny commented 6 years ago

how can i use mouseover to change color with js?

rachael-tomaszewski commented 6 years ago

This is what I have for my mouseover function:

'''var shapes = document.querySelectorAll('.shape'); shapes.forEach(function(shape, i) { shape.addEventListener('mouseover', function(event) {

if (shape.classList.contains('shape-interaction')) {
   shape.classList.remove('shape-interaction');
} else {

shape.classList.add('shape-interaction'); }'''

I would imagine if you set color changing as the function, this should work for you. But personally I find color changing easier with CSS so I'd recommend that unless you're really adamant on using js.