Jquery 在更改样式时显示和隐藏内容
我有一个带有标签的导航栏。当点击某个选项卡时,该选项卡应处于活动状态,即css应更改。此外,应隐藏以前的内容并显示新内容,但我的行为与我希望的不同: 我做错了什么 因此需要一些代码这里是一些js:Jquery 在更改样式时显示和隐藏内容,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,我有一个带有标签的导航栏。当点击某个选项卡时,该选项卡应处于活动状态,即css应更改。此外,应隐藏以前的内容并显示新内容,但我的行为与我希望的不同: 我做错了什么 因此需要一些代码这里是一些js: $(document).ready(function(){ $('.profileSubpage:gt(0)').hide(); $(document).on('click','ul.profileTabs li',function(e){ e.preventDef
$(document).ready(function(){
$('.profileSubpage:gt(0)').hide();
$(document).on('click','ul.profileTabs li',function(e){
e.preventDefault();
var number = $(this).index();
$(".profileSubpage").hide().eq((this).index()).show();
$(this).addClass("active").siblings().removeClass("active");
});
});
您的代码中有一个错误:
eq((this).index())
应该是:
eq($(this).index())
您的代码中有一个错误:
eq((this).index())
应该是:
eq($(this).index())
您的代码中有一个错误:
eq((this).index())
应该是:
eq($(this).index())
您的代码中有一个错误:
eq((this).index())
应该是:
eq($(this).index())
我已经修改了你的代码。检查
$(document).on('click','ul.profileTabs li',function(e){
e.preventDefault();
var number = $(this).index();
$(".profileSubpage").hide();
$(".profileSubpage:eq("+number+")").show();
$(this).addClass("active").siblings().removeClass("active");
});
我已经修改了你的代码。检查
$(document).on('click','ul.profileTabs li',function(e){
e.preventDefault();
var number = $(this).index();
$(".profileSubpage").hide();
$(".profileSubpage:eq("+number+")").show();
$(this).addClass("active").siblings().removeClass("active");
});
我已经修改了你的代码。检查
$(document).on('click','ul.profileTabs li',function(e){
e.preventDefault();
var number = $(this).index();
$(".profileSubpage").hide();
$(".profileSubpage:eq("+number+")").show();
$(this).addClass("active").siblings().removeClass("active");
});
我已经修改了你的代码。检查
$(document).on('click','ul.profileTabs li',function(e){
e.preventDefault();
var number = $(this).index();
$(".profileSubpage").hide();
$(".profileSubpage:eq("+number+")").show();
$(this).addClass("active").siblings().removeClass("active");
});