jquery Tab效果和動(dòng)態(tài)加載的簡(jiǎn)單實(shí)例
一:tab效果顯示
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>無(wú)標(biāo)題頁(yè)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script src="js/jquery-1.4.2-vsdoc.js" type="text/javascript"></script>
<style>
html{ font-size:12px;}
body{ margin:50px;}
div,ul,li{ margin:0; padding:0;}
#tab{ width:200px; margin-top:20px;}
#tab li{ float:left; height:20px; line-height:20px; border:1px solid #000; list-style:none; padding:3px 6px;}
#tab li.on{ background:#3CF;}
#bd div{ width:198px; border:1px solid #000; height:100px; text-align:center; line-height:100px;background:#3CF;}
#links a{ margin-right:10px;}
</style>
</head>
<body>
<span id="links"><a href="#">登錄</a><a href="#">注冊(cè)</a></span>
<ul id="tab">
<li class="on">登錄</li>
<li>注冊(cè)</li>
<div style="clear:both;"></div>
</ul>
<div id="bd">
<div>登錄內(nèi)容</div>
<div>注冊(cè)內(nèi)容</div>
</div>
<script type="text/javascript">
$(function() {
$("#bd>div:not(:first)").hide(); //取id為bd下面第一個(gè)div,并且將不是第一個(gè)的隱藏起來(lái)
$("#tab li").mouseover(function() { //當(dāng)鼠標(biāo)移動(dòng)過(guò)id為tab 下面li標(biāo)簽時(shí)觸發(fā)函數(shù)
var index = $("#tab li").index(this);//取當(dāng)前事件時(shí)的索引記錄在index里面
$(this).addClass("on").siblings().removeClass("on"); //將當(dāng)前事件上加上樣式“on”,并且將兄弟節(jié)點(diǎn)的樣式全部移除
//siblings()是取到兄弟節(jié)
$("#bd>div").eq(index).show().siblings().hide(); //將id為bd下面的第 index個(gè)div顯示出來(lái),將兄弟隱藏(如:$("p:eq(1)")意思是”選擇第二個(gè) <p> 元素“)
});
// $("#links a").mouseover(function() {
// var index = $("#links a").index(this);
// $("#tab li").eq(index).trigger("click");
// });
});
</script>
</body>
</html>
二:Tab效果和動(dòng)態(tài)加載
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="js/jquery-1.4.2-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#bd>div:not(:first)").hide();
$("#tab td").mouseover(function() {
var index = $("#tab td").index(this);
$("#bd>div").eq(index).show().siblings().hide();
});
$("#bd a").click(function() {
var link = $("<td><a );
var links = $("<div><a ).append(link); //向id為tab下面追加link
$("#bd").append(links); //向id為bd下面追加links
});
});
</script>
<style type="text/css">
#tab li.on
{
background: #3CF;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr id="tab">
<td>
<a >百度</a>
</td>
<td>
<a >博客園</a>
</td>
<td>
<a >好123</a>
</td>
<td>
<a >163</a>
</td>
</tr>
</table>
<div id="bd">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<%#Eval("StationName") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
asfa
</HeaderTemplate>
<ItemTemplate>
<%#Eval("StationName")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
azsac
</HeaderTemplate>
<ItemTemplate>
<%#Eval("StationName")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
azsac
</HeaderTemplate>
<ItemTemplate>
<a href="#">
<%#Eval("StationName")%></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Business" HeaderText="Business"/>
<asp:BoundField DataField="Status" HeaderText="Status"/>
<asp:BoundField DataField="Certificate" HeaderText="Certificate"/>
</Columns>
</asp:GridView>
</div>
<div>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Business" HeaderText="Business"/>
<asp:BoundField DataField="Business" HeaderText="Business"/>
<asp:BoundField DataField="Business" HeaderText="Business"/>
<asp:BoundField DataField="Business" HeaderText="Business"/>
<asp:BoundField DataField="Status" HeaderText="Status"/>
<asp:BoundField DataField="Certificate" HeaderText="Certificate"/>
</Columns>
</asp:GridView>
</div>
<div>
<asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Business" HeaderText="Business"/>
<asp:BoundField DataField="Status" HeaderText="Status"/>
<asp:BoundField DataField="Certificate" HeaderText="Certificate"/>
<asp:BoundField DataField="Status" HeaderText="Status"/>
</Columns>
</asp:GridView>
</div>
</div>
</form>
</body>
</html>
- 動(dòng)態(tài)加載jQuery的方法
- jQuery結(jié)合ajax實(shí)現(xiàn)動(dòng)態(tài)加載文本內(nèi)容
- jQuery實(shí)現(xiàn)頁(yè)面滾動(dòng)時(shí)動(dòng)態(tài)加載內(nèi)容的方法
- 使用jquery動(dòng)態(tài)加載js文件的方法
- 一個(gè)簡(jiǎn)單的動(dòng)態(tài)加載js和css的jquery代碼
- 三種動(dòng)態(tài)加載js的jquery實(shí)例代碼另附去除js方法
- 動(dòng)態(tài)加載jquery庫(kù)的方法
- jquery動(dòng)態(tài)加載select下拉框示例代碼
- 動(dòng)態(tài)加載jQuery的兩種方法實(shí)例分析
相關(guān)文章
jquery編寫彈出信息提示條并延時(shí)滑出動(dòng)畫實(shí)現(xiàn)示例
這篇文章主要為大家介紹了jquery編寫彈出信息提示條并延時(shí)滑出動(dòng)畫實(shí)現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08JQuery對(duì)ASP.NET MVC數(shù)據(jù)進(jìn)行更新刪除
這篇文章主要介紹了JQuery對(duì)ASP.NET MVC數(shù)據(jù)進(jìn)行更新刪除的相關(guān)資料,需要的朋友可以參考下2016-07-07jQuery實(shí)現(xiàn)獲取隱藏div高度的方法示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)獲取隱藏div高度的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了jQuery針對(duì)頁(yè)面元素屬性操作的相關(guān)技巧,需要的朋友可以參考下2017-02-02jquery實(shí)現(xiàn)動(dòng)態(tài)創(chuàng)建form并提交的方法示例
這篇文章主要介紹了jquery實(shí)現(xiàn)動(dòng)態(tài)創(chuàng)建form并提交的方法,結(jié)合實(shí)例形式分析了jQuery form表單創(chuàng)建與提交相關(guān)操作技巧,需要的朋友可以參考下2019-05-05基于json的jquery地區(qū)聯(lián)動(dòng)效果代碼
貼一個(gè)基于jquery聯(lián)動(dòng)的代碼,相信這樣的代碼有一大把,就當(dāng)是jquery的練手吧2011-07-07淺談jQuery中ajaxPrefilter的應(yīng)用
下面小編就為大家?guī)?lái)一篇淺談jQuery中ajaxPrefilter的應(yīng)用。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-08-08jQuery UI Datepicker length為空或不是對(duì)象錯(cuò)誤的解決方法
jQuery UI Datepicker length為空或不是對(duì)象錯(cuò)誤的解決方法,需要的朋友可以參考下。2010-12-12