Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我无法使用javascript切换选项卡_Javascript_Html_Css - Fatal编程技术网

我无法使用javascript切换选项卡

我无法使用javascript切换选项卡,javascript,html,css,Javascript,Html,Css,当我尝试从注册切换到登录时,我无法切换,因此请帮助我查找问题。我认为我的javascript中存在问题,因为其余的都可以正常工作 以下是我的html代码: <div class="form"> <ul class="tab-group"> <li class="tab active"><a href="#signup">Sign Up</a></li> <li class="tab"><

当我尝试从注册切换到登录时,我无法切换,因此请帮助我查找问题。我认为我的javascript中存在问题,因为其余的都可以正常工作

以下是我的html代码:

<div class="form">

  <ul class="tab-group">
    <li class="tab active"><a href="#signup">Sign Up</a></li>
    <li class="tab"><a href="#login">Log In</a></li>
  </ul>

  <div class="tab-content">
    <div id="signup">   
      <h1>Sign Up for Free</h1>

      <form action="/" method="post">

      <div class="top-row">
        <div class="field-wrap">
          <label>
            First Name<span class="req">*</span>
          </label>
          <input type="text" required autocomplete="off" />
        </div>

        <div class="field-wrap">
          <label>
            Last Name<span class="req">*</span>
          </label>
          <input type="text"required autocomplete="off"/>
        </div>
      </div>

      <div class="field-wrap">
        <label>
          Email Address<span class="req">*</span>
        </label>
        <input type="email"required autocomplete="off"/>
      </div>

      <div class="field-wrap">
        <label>
          Set A Password<span class="req">*</span>
        </label>
        <input type="password"required autocomplete="off"/>
      </div>

      <button type="submit" class="button button-block"/>Get        Started</button>

      </form>

    </div>

    <div id="login">   
      <h1>Welcome Back!</h1>

      <form action="/" method="post">

        <div class="field-wrap">
        <label>
          Email Address<span class="req">*</span>
        </label>
        <input type="email"required autocomplete="off"/>
      </div>

      <div class="field-wrap">
        <label>
          Password<span class="req">*</span>
        </label>
        <input type="password"required autocomplete="off"/>
      </div>

      <p class="forgot"><a href="#">Forgot Password?</a></p>

      <button class="button button-block"/>Log In</button>

      </form>

    </div>

       </div><!-- tab-content -->

         </div> <!-- /form -->
以下是我的javascript和令人不安的部分:

     $('.form').find('input, textarea').on('keyup blur focus', function (e)  { 

    var $this = $(this),
    label = $this.prev('label');

      if (e.type === 'keyup') {
        if ($this.val() === '') {
      label.removeClass('active highlight');
     } else {
      label.addClass('active highlight');
    }
      } else if (e.type === 'blur') {
     if( $this.val() === '' ) {
        label.removeClass('active highlight'); 
        } else {
        label.removeClass('highlight');   
        }   
         } else if (e.type === 'focus') {

          if( $this.val() === '' ) {
        label.removeClass('highlight'); 
        } 
         else if( $this.val() !== '' ) {
        label.addClass('highlight');
        }
         }

        });

        $('.tab a').on('click', function (e) {

         e.preventDefault();

         $(this).parent().addClass('active');
         $(this).parent().siblings().removeClass('active');

           target = $(this).attr('href');

             $('.tab-content > div').not(target).hide();

              $(target).fadeIn(600);

              });

在html中,您的按钮标签上有一个打字错误(
),但按钮标签不需要像输入一样关闭

之后,确保加载了正确的JS库

您的代码运行良好,然后:

这是你的一堆代码->


希望能有帮助

在html中,按钮的标记(
)上有输入错误,但按钮的标记不需要像输入一样关闭

之后,确保加载了正确的JS库

您的代码运行良好,然后:

这是你的一堆代码->


希望能有帮助

您将关闭
元素两次<代码>开始删除第一个
/
。两个按钮都有。如果我的答案解决了你的问题,你可以通过点击投票柜台下方的绿色tic来验证我的答案。谢谢@阿德里安·勒伯:我已经对你的答案投了赞成票,应该有一个小部件出现在有@Legends的人面前,呵呵,我同意。谢谢你的投票@哇,干得好!谢谢您将关闭
元素两次<代码>开始删除第一个
/
。两个按钮都有。如果我的答案解决了你的问题,你可以通过点击投票柜台下方的绿色tic来验证我的答案。谢谢@阿德里安·勒伯:我已经对你的答案投了赞成票,应该有一个小部件出现在有@Legends的人面前,呵呵,我同意。谢谢你的投票@哇,干得好!谢谢
     $('.form').find('input, textarea').on('keyup blur focus', function (e)  { 

    var $this = $(this),
    label = $this.prev('label');

      if (e.type === 'keyup') {
        if ($this.val() === '') {
      label.removeClass('active highlight');
     } else {
      label.addClass('active highlight');
    }
      } else if (e.type === 'blur') {
     if( $this.val() === '' ) {
        label.removeClass('active highlight'); 
        } else {
        label.removeClass('highlight');   
        }   
         } else if (e.type === 'focus') {

          if( $this.val() === '' ) {
        label.removeClass('highlight'); 
        } 
         else if( $this.val() !== '' ) {
        label.addClass('highlight');
        }
         }

        });

        $('.tab a').on('click', function (e) {

         e.preventDefault();

         $(this).parent().addClass('active');
         $(this).parent().siblings().removeClass('active');

           target = $(this).attr('href');

             $('.tab-content > div').not(target).hide();

              $(target).fadeIn(600);

              });