gpt4 book ai didi

javascript - 如何正确地进行 Bootstrap 选项卡替换?

转载 作者:行者123 更新时间:2023-11-30 00:29:00 25 4
gpt4 key购买 nike

我有三个选项卡,每个选项卡都包含一个表单,当我单击选项卡进行登录时,我将使用此 jsfiddle 中指定的 animate.css 和 jquery 将其替换为忘记密码的选项卡。

现在,我添加了另一个选项卡,切换到非替换选项卡会加载先前加载选项卡下方的选项卡,如此处所示 jsfiddle .

我希望在单击“注册”选项卡时隐藏“登录/忘记密码”选项卡的内容。

我已经尝试使用 tab('show') 和基于 boolean 的点击事件处理程序来解决这个问题,如下所示:

window.isHazardousForRegister = false;

$('.forgot-password-header').css('display', 'none');

$('#forgot-password').on('click', function(e) {
isHazardousForRegister = true;
e.preventDefault();

$('#login-form')
.addClass('animated fadeOutLeft')
.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$('.login-form-header').css('display', 'none');

$('#login-form').css({
'display': 'none',
'visibility': 'hidden'
});

$('.forgot-password-header')
.css('display', 'block')
.addClass('active');

$('#forgot-password-tab')
.removeClass('fadeOutLeft')
.addClass('animated fadeInRight')
.css({
'display': 'block',
'visibility': 'visible'
});

});
});

$('.back-to-login').on('click', function(e) {
isHazardousForRegister = true
e.preventDefault();

$('.forgot-password-header')
.css('display', 'none')
.removeClass('active');

$('#forgot-password-tab')
.removeClass('fadeInRight')
.addClass('fadeOutLeft')
.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$('#forgot-password-tab').css({
'display': 'none',
'visibility': 'hidden'
});
$('.login-form-header')
.css('display', 'block')
.addClass('active');
$('#login-form')
.removeClass('fadeOutLeft')
.addClass('fadeInRight')
.css({
'display': 'block',
'visibility': 'visible'
});
});
});

$('.register-form-header').on('click', function() {
if (isHazardousForRegister) {
$('#forgot-password-header').removeClass('active').tab('hide');

$('#forgot-password').css({
'display': 'none',
'visibility': 'hidden'
});

$('#login-form').css({
'display': 'none',
'visibility': 'hidden'
});

$('#login-form-header').removeClass('active').tab('hide');
$(this).addClass('active').tab('show');
}
});

最佳答案

我不知道这是不是好方法但是我解决了这个..

这是javascript

$('.forgot-password-header').css('display', 'none');
$('#forgot-password').on('click', function(e) {
e.preventDefault();
$('#login-form')
.addClass('animated fadeOutLeft')
.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$('.login-form-header')
.css('display', 'none')
.removeClass('active');
$('#login-form').css('display', 'none');
$('.forgot-password-header')
.css('display', 'block')
.addClass('active');

$('#forgot-password-tab')
.addClass('animated fadeInRight')
.css('display', 'block');
});

});

$('.back-to-login').on('click', function(e) {
e.preventDefault();
$('.forgot-password-header')
.css('display', 'none')
.removeClass('active');
$('#forgot-password-tab')
.removeClass('fadeInRight')
.addClass('fadeOutLeft')
.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$('#forgot-password-tab').css('display', 'none');
$('.login-form-header')
.css('display', 'block')
.addClass('active');
$('#login-form')
.removeClass('fadeOutLeft')
.addClass('fadeInRight')
.css('display', 'block');
});
});
$('.login-form-header').on('click', function(e) {
e.preventDefault();
$('#login-form').show();
});
$('.forgot-password-header').on('click', function(e) {
e.preventDefault();
$('#forgot-password-tab').show();
});
$('.register-form-header').on('click', function(e) {
e.preventDefault();
$('#login-form').hide();
$('#forgot-password-tab').hide();
});

工作示例是 here

关于javascript - 如何正确地进行 Bootstrap 选项卡替换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30302258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com