尝试使下一个和上一个按钮出现在注册表单的不同时间

问题描述 投票:0回答:1

您好我正在尝试为我的网站制作我的注册表单,我正在进行下一个和之前的浏览我的网站,我有下一个和上一个工作得很好,但我希望上一个按钮隐藏我在第一个问题时登记标志显示我在最后一个问题上。

这是我的JS

      var nameRegistration = document.querySelector('.name- 
      registration');
      var emailRegistration = document.querySelector('.email- 
      registration');
      var industriesRegistration = document.querySelector('.industries- 
      registration');
      var birthRegistration = document.querySelector('.birth- 
      registration');
      var passwordRegistration = document.querySelector('.password-registration');

var nextContainer = document.querySelector('#forward');
var backContainer = document.querySelector('#back');
var registerContainer = document.querySelector('#register-btn-container');

  if (nameRegistration.style.display === 'none ') {
    backContainer.style.display = 'block'
} 

  if (passwordRegistration.style.display === 'block') {
    registerContainer.style.display = 'block'
}
javascript html css
1个回答
0
投票

您可以通过多种方式实现这一目标,例如,保持计数器以了解您所处理的过程中的每个部分,并在每个“部分”变更中保持递增和递减,并相应地采取相应措施。

checkSection编辑您需要的选项/字段。

let activeSection = 0;

const checkSection = position => {
//if not in the start, hide start section/button/option
 if(position == 0) {
   document.getElementById('id').style.display = 'none';
   document.getElementById('otherid').style.display = 'block';
}
 else { 
  document.getElementById('id').style.display = 'none';
  document.getElementById('otherid').style.display = 'block';
  } 
}

//and control where you are with listeners to the clicks
document.getElementById('linkmoveup').addEventListener('click',function(e){
   //don't follow link
   e.preventDefault();
   //lets assume this is for the next point, increment position counter
   activeSection++;
   //recheck for what is active
   checkSection(activeSection);
});
© www.soinside.com 2019 - 2024. All rights reserved.