一、标签切换
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <link href="app.css" rel="stylesheet"/> <script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="jquery-1.10.1.min.js"></script> <script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="app.js"></script> </head> <body> <ul id="tabfirst"> <li class="tabin">标签1</li> <li>标签2</li> <li>标签3</li> </ul> <div class="content contentfirst"> 内容1 </div> <div class="contentfirst"> 内容2 </div> <div class="contentfirst"> 内容3 </div> </body></html>
ul,li{ margin: 0; padding: 0; list-style: none;}li{ float: left; background-color: #868686; color: #FFFFFF; padding: 5px; margin-right: 2px; border: 1px solid white;}.tabin{ background-color: #6e6e6e; border: 1px solid #6e6e6e;}.contentfirst{ clear: both; background-color: #6e6e6e; color: #FFFFFF; width: 300px; height: 100px; padding: 10px; display: none;}.content{ display: block;}
var timeoutid;$(document).ready(function(){ $("#tabfirst li").each(function(index){ var liNode = $(this); $(this).mouseover(function(){ timeoutid=setTimeout(function(){ $("div.content").removeClass("content"); $("#tabfirst li.tabin").removeClass("tabin"); $("div").eq(index).addClass("content"); liNode.addClass("tabin"); },300) }).mouseout(function(){ clearTimeout(timeoutid); }) });});
二、标签切换数据加载
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <link href="app.css" rel="stylesheet"/> <script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="jquery-1.10.1.min.js"></script> <script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="app.js"></script> </head> <body> <ul id="tabfirst"> <li class="tabin">标签1</li> <li>标签2</li> <li>标签3</li> </ul> <div class="content contentfirst"> 内容1 </div> <div class="contentfirst"> 内容2 </div> <div class="contentfirst"> 内容3 </div> <br /> <br /> <br /> <br /> <ul id="tabsecond"> <li class="tabin">装载完整页面</li> <li>装载部分页面</li> <li>装载网络数据</li> </ul> <div id="contentsecond"> <div id="realcontent"> </div> </div> </body></html>
ul,li{ margin: 0; padding: 0; list-style: none;}li{ float: left; background-color: #868686; color: #FFFFFF; padding: 5px; margin-right: 2px; border: 1px solid white;}.tabin{ background-color: #6e6e6e; border: 1px solid #6e6e6e;}.contentfirst{ clear: both; background-color: #6e6e6e; color: #FFFFFF; width: 300px; height: 100px; padding: 10px; display: none;}.content{ display: block;}#tabsecond li{ float: left; background-color: #FFFFFF; color: blue; padding: 10px; margin-right: 2px; cursor: pointer;}#tabsecond li.tabin{ background-color: #f2f6f8; border: 1px solid #000000; border-bottom: 0; z-index: 100; position: relative;}#contentsecond{ width: 500px; height: 200px; padding: 10px; background-color: #F2F6F8; clear: left; border: 1px solid #000000; top: -2px; position: relative;}
var timeoutid;$(document).ready(function(){ $("#tabfirst li").each(function(index){ var liNode = $(this); $(this).mouseover(function(){ timeoutid=setTimeout(function(){ $("div.content").removeClass("content"); $("#tabfirst li.tabin").removeClass("tabin"); $("div").eq(index).addClass("content"); liNode.addClass("tabin"); },300) }).mouseout(function(){ clearTimeout(timeoutid); }) }); $("#realcontent").load("mytab.html"); $("#tabsecond li").each(function(index){ $(this).click(function(){ $("#tabsecond li.tabin").removeClass("tabin"); $(this).addClass("tabin"); if(index==0){ $("#realcontent").load("mytab.html"); }else if(index == 1){ $("#realcontent").load("mytab.html"); }else if(index == 2){ $("#realcontent").load("mytab.html"); } }) })});
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body> <div> 你好么??? <h2> <% out.print("你好,这里是jsp"); %> </h2> </div></body></html>
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦