结构:
.s-content >.tab
.s-content >.inner
想要的结果是在不同大层里点击tab切换对应顺序的inner
//网址tab var wTag=$("#s_nall_tabs a"); wTag.each(function(){ $(this).click(function(i){ wTag.removeClass("tab-on"); var index=$("#s_nall_tabs a").index(this); $(this).addClass("tab-on"); $("#s_nall_tabs_con .inner").hide(); $("#s_nall_tabs_con .inner").eq(index).show(); }) }); //网址tab var sTag=$(".s-gbuy-hd a"); sTag.each(function(){ $(this).click(function(i){ sTag.removeClass("tab-on"); var index=$(".s-gbuy-hd a").index(this); $(this).addClass("tab-on"); $(".s-gbuy .inner").hide(); console.log(index); $(".s-gbuy .inner").eq(index).show(); }) });
回复讨论(解决方案)
var wTag=$("#s_nall_tabs a,.s-gbuy-hd a");
wTag.each(function(){
$(this).click(function(i){
wTag.removeClass("tab-on");
var index=$("#s_nall_tabs a").index(this);
$(this).addClass("tab-on");
$("#s_nall_tabs_con .inner").hide();
$("#s_nall_tabs_con .inner").eq(index).show();
})
});
var wTag=$("#s_nall_tabs a,.s-gbuy-hd a");
wTag.each(function(){
$(this).click(function(i){
wTag.removeClass("tab-on");
var index=$("#s_nall_tabs a").index(this);
$(this).addClass("tab-on");
$("#s_nall_tabs_con .inner").hide();
$("#s_nall_tabs_con .inner").eq(index).show();
})
});
哇,原来可以这样。。。。我感动哭了要。。。。谢谢 ~
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Tab</title></head><body> <style> .tab-on { background-color: green; } </style> <div class="s-content"> <div class="tab"> <a class="tab-on" href="#" id="tab-1">Tab-1</a> <a href="#" id="tab-2">Tab-2</a> <a href="#" id="tab-3">Tab-3</a> </div> <div class="inner" data-for="tab-1"> <p>tab-1 content!</p> </div> <div class="inner" data-for="tab-2" style="display: none;"> <p>tab-2 content!</p> </div> <div class="inner" data-for="tab-3" style="display: none;"> <p>tab-3 content!</p> </div> </div> <script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script> <script> $( ".s-content .tab a" ).click( function () { var tabIndex = $( this ).index(); $( this ).addClass( "tab-on" ); // 给点击的 tab 加上 “.tab-on” $( this ).siblings().removeClass( "tab-on" ); // 其他的 tab 去掉 “.tab-on” $( ".s-content .inner" ).hide().eq( tabIndex ).show(); } ); </script></body></html>
var wTag=$(".s-content .tab"); wTag.each(function(){ $(this).click(function(i){ var p=$(this).parents(".s-content"); var tabs=p.find(".tab"); var index=tabs.index(this); tabs.removeClass("tab-on"); $(this).addClass("tab-on"); p.find(".inner").hide(); p.find(".inner").eq(index).show(); }) });
再修理好点~
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Tab</title></head><body> <style> .tab-on { background-color: green; } </style> <div class="s-content"> <div class="tab"> <a class="tab-on" href="#" id="tab-1">Tab-1</a> <a href="#" id="tab-2">Tab-2</a> <a href="#" id="tab-3">Tab-3</a> </div> <div class="inner" data-for="tab-1"> <p>tab-1 content!</p> </div> <div class="inner" data-for="tab-2" style="display: none;"> <p>tab-2 content!</p> </div> <div class="inner" data-for="tab-3" style="display: none;"> <p>tab-3 content!</p> </div> </div> <script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script> <script> $( ".s-content .tab a" ).click( function () { var tabIndex = $( this ).index(); $( this ).addClass( "tab-on" ); // 给点击的 tab 加上 “.tab-on” $( this ).siblings().removeClass( "tab-on" ); // 其他的 tab 去掉 “.tab-on” $( ".s-content .inner" ).hide().eq( tabIndex ).show(); } ); </script></body></html>
这个当页面有多个s-content 就不行了的

htmlattributesarecrucialinwebdevelopment forcontrollingBehavior,外观和功能

alt属性是HTML中标签的重要部分,用于提供图片的替代文本。1.当图片无法加载时,alt属性中的文本会显示,提升用户体验。2.屏幕阅读器使用alt属性帮助视障用户理解图片内容。3.搜索引擎索引alt属性中的文本,提高网页的SEO排名。

HTML、CSS和JavaScript在网页开发中的作用分别是:1.HTML用于构建网页结构;2.CSS用于美化网页外观;3.JavaScript用于实现动态交互。通过标签、样式和脚本,这三者共同构筑了现代网页的核心功能。

设置标签的lang属性是优化网页可访问性和SEO的关键步骤。1)在标签中设置lang属性,如。2)在多语言内容中,为不同语言部分设置lang属性,如。3)使用符合ISO639-1标准的语言代码,如"en"、"fr"、"zh"等。正确设置lang属性可以提高网页的可访问性和搜索引擎排名。

htmlattributeseresene forenhancingwebelements'functionalityandAppearance.TheyAdDinformationTodeFineBehavior,外观和互动,使网站互动,响应式,visalalyAppealing.AttributesLikutesLikeSlikEslikesrc,href,href,href,类,类型,类型,和dissabledtransfransformformformformformformformformformformformformformformforment

toCreateAlistinHtml,useforforunordedlistsandfororderedlists:1)forunorderedlists,wrapitemsinanduseforeachItem,RenderingeringAsabulleTedList.2)fororderedlists,useandfornumberedlists,useandfornumberedlists,casundfornumberedlists,customeizableWithTheTtheTthetTheTeTeptTributeFordTributeForderForderForderFerentNumberingSnumberingStyls。

HTML用于构建结构清晰的网站。1)使用标签如、、定义网站结构。2)示例展示了博客和电商网站的结构。3)避免常见错误如标签嵌套不正确。4)优化性能通过减少HTTP请求和使用语义化标签。

toinsertanimageIntoanhtmlpage,usethetagwithsrcandaltattributes.1)usealttextforAcccessibilityandseo.2)instementRcsetForresponSiveImages.3)applylazyloadingWithLoadingWithLoading =“ lazy” tooptimizeperformance.4)tooptimizeperformance.4)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能