M
M
Maxim js2020-04-24 07:01:30
css
Maxim js, 2020-04-24 07:01:30

How to implement such block switching in pure JS?

Tell me how to do the same switching of registration blocks on a javascript cheat https://codepen.io/AlexisBertin/pen/qOMegE here it's done through angular
it's interesting to understand how it can work on pure js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
drawnofmymind, 2020-04-24
@winers

document.querySelector('.buy').addEventListener('click', (e)=>{
  if(e.target){
    document.querySelector('.login-content-signin').style.opacity="0"
     document.querySelector('.login-content-signin').style.zIndex="-1"
        document.querySelector('.login-content-signup').style.opacity="1"
     document.querySelector('.login-content-signup').style.zIndex="1"
  }
})

document.querySelector('.hi').addEventListener('click', (e)=>{
  if(e.target){
    document.querySelector('.login-content-signin').style.opacity="1"
     document.querySelector('.login-content-signin').style.zIndex="1"
        document.querySelector('.login-content-signup').style.opacity="0"
     document.querySelector('.login-content-signup').style.zIndex="-1"
  }
})
      <button ng-click="showSignIn=false" class="hi">Login</button>
      <button ng-click="showSignIn=true" class="buy">Sign Up</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question