hey ! I’m trying to clone make a clone of iPhone 6 calculator
I’m stuck in trying to use Dom manipulation
when im using on click on operators(/ ,*,-,+) I want to change the bg-color to white and font to orange ,it’s works but I’m not able to remove the previous element (active class)
property, how do I access the previous element and change it to default style(remove active class )
link to js fiddle
You are already using classList.add
, you just need to use the corresponding remove method classList.remove
.
And instead of the click
event you could use onMouseDown
and onMouseUp
Couldn’t you just do this with the :active css selector though?
1 Like
thank you !
the remove method works but I had to loop to all 4 button’s
I’ll try the onMouseDown and onMouseUp events instead
:active css selector does the job (turn light orange on clicking) ,but after release I would need click function to stay on dark orange .
I think onMouse up and down eventHandlers will do it.
thank for your help