jQuery 菜單切換

來源:互聯網
上載者:User

標籤:jquery 菜單切換

一、標籤切換   

<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><link href="app.css" rel="stylesheet"/><script src="jquery-1.10.1.min.js"></script><script src="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 src="jquery-1.10.1.min.js"></script><script src="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>


jQuery 菜單切換

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.