How to revert CSS to default using JS?
For example, I have the following code:
div{
position:relative;
width:100px;
height:100px;
top:50px;
}
Then, with JS:
let div = document.getElementsByTagName('DIV')[0]
let n = 0
div.onclick = ()=>{
if(n == 0){
div.style.top = '100px'
n++
}else{
div.style.top = '50px'
n = 0
}
}
As you can see, I need to manually reset the div to it's initial position. Is there anyway I can reset to it's initial position without doing the method above?