用于隐藏/取消隐藏div的Jquery函数无法正常工作 [英] Jquery function for hiding/unhiding div isn't working properly
问题描述
我有两种表格用于登录/注册,另一种用于医院/医生查找器。两种形式都是平面UI形式,即第一种形式包含3个登录,注册和将密码重置为一个表单。我面临的问题是当我点击上面提到的li中的任何一个li时,正好在下面的医院/医生发现者形式变得空白,反之亦然。这是用于在窗体内隐藏/取消隐藏div的jquery函数。功能是明确的,但我无法弄明白,为什么不工作。
需要紧急帮助。提前谢谢。
Jquery功能:
i've two forms one for signin/signup and other for hospital/doctor finder. Both forms are flat UI forms i.e first forms contains 3 li signin,signup & reset password together in a single form. The problem that i'm facing is when i click on any li among above mentioned li's, the hospital/doctor finder form which is exactly below gets blank n vice versa. here's the jquery function for hiding/unhiding divs inside the form. function is unambiguous but i'm unable to figure out, why isn't working.
Need urgent help. thanks in advance.
Jquery function:
$(function () {
// constants
var SHOW_CLASS = 'show',
HIDE_CLASS = 'hide',
ACTIVE_CLASS = 'active';
$('#tabs1').on('click', 'li a', function (e) {
e.preventDefault();
var $tab = $(this),
href = $tab.attr('href');
$('.active').removeClass(ACTIVE_CLASS);
$tab.addClass(ACTIVE_CLASS);
$('.show')
.removeClass(SHOW_CLASS)
.addClass(HIDE_CLASS)
.hide();
$(href)
.removeClass(HIDE_CLASS)
.addClass(SHOW_CLASS)
.hide()
.fadeIn(550);
});
});
$(function () {
// constants
var SHOW_CLASS = 'show',
HIDE_CLASS = 'hide',
ACTIVE_CLASS = 'active';
$('#tabs2').on('click', 'li a', function (e) {
e.preventDefault();
var $tab = $(this),
href = $tab.attr('href');
$('.active').removeClass(ACTIVE_CLASS);
$tab.addClass(ACTIVE_CLASS);
$('.show')
.removeClass(SHOW_CLASS)
.addClass(HIDE_CLASS)
.hide();
$(href)
.removeClass(HIDE_CLASS)
.addClass(SHOW_CLASS)
.hide()
.fadeIn(550);
});
});
推荐答案
( function (){
// 常量
var SHOW_CLASS = ' show',
HIDE_CLASS = ' hide',
ACTIVE_CLASS = ' active';
(function () { // constants var SHOW_CLASS = 'show', HIDE_CLASS = 'hide', ACTIVE_CLASS = 'active';
(' #tabs1')。on(' click',' li a', function (e){
e.preventDefault();
var
('#tabs1').on('click', 'li a', function (e) { e.preventDefault(); var
tab =
这篇关于用于隐藏/取消隐藏div的Jquery函数无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!