Home > OS >  javascript code do not redirect to destinated part
javascript code do not redirect to destinated part

Time:12-26

my js code is not working

js code:

const signUpPageLink = document.querySelector('#signup-page-link');
const loginPageLink = document.querySelector('#login-page-link');
const wrapper = document.querySelector('.wrapper');

signUpPageLink.addEventListener('click',function(){
    wrapper.style.top = '-100%';
})

loginPageLink.addEventListener('click',function(){
    wrapper.style.top = '0%';
})

it should go to a "register" part. it just dont work! i dont know more what to do, i really need help.

Tried so many ways but it didnt worked

CodePudding user response:

You could try:

signUpPageLink.addEventListener('click',function(){
    wrapper.style.top = '-100%';
    location.replace("https://www.example.com/register")
})

Or:

signUpPageLink.addEventListener('click',function(){
    wrapper.style.top = '-100%';
    location.href("https://www.example.com/register")
})
  • Related