繁体   English   中英

JS点击功能不响应

[英]JS click function doesn't respond

请看一下这个页面。 我在此页面上为每个按钮(#signup_switch_btn和#signin_switch_btn,红色和绿色的大按钮)编写了单击功能,但是没有人响应。 http://tural.no-ip.org/-实际页面。 JS文件-first.js

Js看起来像这样

$(document).ready(function () {
    $('#signup_form').get(0).reset()
    var counter = 0,
signin = $("#signin_switch_btn"), 
signup = $("#signup_switch_btn"), 
signin_f = $("#signin_form"), 
holder = $("#holder"), 
signup_f = $("#signup_form"), 
f_container = $("#form_container");


    function beforeAnimation() {
        signin.removeClass('default_radius').addClass('right_radius');
        signup.removeClass('default_radius').addClass('left_radius');
        $("#container").animate({
            marginTop: "-=150px",
        }, 500);
    }


    $("#signup_switch_btn").click(function () {

        if (counter === 0) {
            beforeAnimation();
            holder.css('backgroundColor', '#f91c06').height(275).slideDown("slow");
            f_container.show();
            signup_f.stop(true, true).fadeIn(1200);
        } else {
            holder.stop(true, true).animate({
                height:"275",
                backgroundColor:"#f91c06"
            },1000);
            signin_f.stop(true, true).fadeOut(1000);
            f_container.stop(true, true).animate({
                height:"260"
            },1000);
            signup_f.stop(true, true).fadeIn(1000);
        }
        counter++;
    });

    $("#signin_switch_btn").click(function () {
        if (counter === 0) {
            beforeAnimation();
            holder.css('backgroundColor', '#5bd300').height(125).slideDown("slow");
            f_container.show();
            signin_f.stop().fadeIn(1200);
        } else {
            holder.stop(true, true).animate({
                height:"125",
                backgroundColor:"#5bd300"
            },1000);
            signup_f.stop(true, true).fadeOut(800);
            f_container.stop(true, true).animate({
                height:"110"
            },1000);
            signin_f.stop(true, true).fadeIn(1200);

        }

        counter++;
    });

    $('input[type="text"],input[type="password"]').focus(function () {
        labelFocus(this, true);
    }).blur(function () {
        labelFocus(this, false);
    });

    function labelFocus(el, focused) {
        var name = $(el).attr('name');
        $('label[for="' + name + '"]').toggleClass('focused', !! focused);
    }
    $('input[type="text"],input[type="password"]').keypress(function () {
        $(this).attr('class', 'valid');
    }); 

});

该页面中signup_switch_btn存在ID为signup_switch_btn元素。 因此,以下绑定将永远无法工作:

$("#signup_switch_btn").click

您在html页面上的ID正在签名和注册。 将$('#signup_switch_btn')更改为$('#signup')

没有ID为* signin_switch_btn *和* signup_switch_btn *的按钮。 您按钮的ID为signinsignup

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM