我目前在登录框中遇到了一些问题。我使用我自己的版本,逻辑背后的逻辑是tutorial online。现在一切正常。当我点击我的登录按钮时,JQuery触发器显示分配给它的类active的窗口。一旦登录框出现,用户可以在登录框中点击登记,并且注册窗口变为活动状态。我知道我在这里可能有点难,但问题应该相当简单。我想按LOGIN旁边的一个新按钮,将用户直接带到REGISTER。为此,我需要根据我按哪个按钮将active状态设置为不同的形式。我试图制作一个js脚本,用于检测哪个链接已被点击,然后将活动状态设置为该窗体。所以第一个代码是链接,现在他们都在登录阶段打开登录框。但我的目标是让第二个人打开注册阶段。这可能吗?如何在一次点击中将活动状态设置为正确的形式?通过单击链接更改div的活动状态
HTML
Login Register的Javascript
$(function() {
//the form wrapper (includes all forms)
var $form_wrapper = $('#login-box'),
//the current form is the one with class active
$currentForm = $form_wrapper.children('form.active'),
//the change form links
$linkform = $form_wrapper.find('.linkform');
$linkform.bind('click', function(e) {
var $link = $(this);
var target = $link.attr('rel');
$currentForm.fadeOut(400, function() {
//remove class active from current form
$currentForm.removeClass('active');
//new current form
$currentForm = $form_wrapper.children('form.' + target);
//animate the wrapper
$form_wrapper.stop()
.animate({
height: $currentForm.data('height') + 'px'
}, 500, function() {
//new form gets class active
$currentForm.addClass('active');
//show the new form
$currentForm.fadeIn(400);
});
});
e.preventDefault();
});
});
+0
你能为此安排一把小提琴 –
+0