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

时间:2018-12-07 16:08:56

标签: javascript html css

您好,我正在尝试为自己的网站制作注册表格,我正在做下一个和上一个要浏览我的网站,我的下一个和上一个工作正常,但是我希望上一个按钮隐藏时,第一个问题,以及我在上一个问题时要显示的注册标志。

这是我的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'
}

1 个答案:

答案 0 :(得分: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);
});