免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
寫(xiě)給設(shè)計(jì)人的10個(gè)jQuery特效(表格樹(shù)插件)

jQuery已經(jīng)不是什么新鮮的事兒,記得第一次聽(tīng)說(shuō)是在catch the digital flow上??偘阉J(rèn)為是非常難的東西,也就沒(méi)有認(rèn)真去了解他了。直到學(xué)完CSS的大部分內(nèi)容,才開(kāi)始接觸這種”write less, do more” 的Javascrīpt框架。今天,這篇文章的最重要內(nèi)容是來(lái)自Web Designer Wall的一篇教程,一篇包含了10個(gè)jQuery特效的教程。這里不打算全文翻譯,想以自己的語(yǔ)言來(lái)表達(dá),或許這樣更方便大家理解/自己以后學(xué)習(xí),也可能更準(zhǔn)確地描述。

提示:教程中所用的 jQuery 版本為1.2.3。這篇文章是為jQuery新手而寫(xiě)的。

先試試看? View jQuery DemosDownload Demo ZIP

jQuery是如何工作的?

首先,你需要下載一個(gè)jQuery版本,并將它插入到<head>標(biāo)簽內(nèi)。然后,你將需要寫(xiě)函數(shù)來(lái)告訴jQuery做些什么,下面的這個(gè)圖表將告訴你jQuery是怎樣工作的(點(diǎn)擊圖片,查看大圖):

!

如何獲取元素(Get the element)?

書(shū)寫(xiě) jQuery 函數(shù)是一個(gè)非常簡(jiǎn)單的事(多虧了精彩的說(shuō)明書(shū))。關(guān)鍵是你要學(xué)習(xí)如何獲取你想要實(shí)現(xiàn)的效果的確切元素。

  • $("#header") = 獲取 id=”header” 的元素
  • $("h3") = 獲取所有<h3>
  • $("div#content .photo") = 獲取<div id=”content”>里所有用class=”photo”定義的元素
  • $("ul li") = 獲取所以 <ul> 中 <li> 的元素
  • $("ul li:first") = 只獲取<ul>中第一個(gè)<li>

1. 簡(jiǎn)單的下拉面板

讓我們來(lái)開(kāi)始這個(gè)簡(jiǎn)單的下拉面板特效吧(view demo),或許你已經(jīng)見(jiàn)過(guò)很多次,現(xiàn)在,自己試試吧:

當(dāng)包含class=”btn-slide”的元素被點(diǎn)擊,它會(huì)下拉/上提<div id=”panel”>里的元素。然后切換到CSS中的class=”active”到<a class=”btn-slide”>元素。.active 將會(huì)以CSS的方式打開(kāi)/關(guān)閉出面板。

$(document).ready(function(){$(".btn-slide").click(function(){	  $("#panel").slideToggle("slow");	  $(this).toggleClass("active");	});});

2. 簡(jiǎn)單的隱藏效果

如圖,當(dāng)右上角的上圖標(biāo)被點(diǎn)擊時(shí),內(nèi)容被隱藏。效果可以看Demo (view demo)

當(dāng)被定義為 <img> 的圖片被點(diǎn)擊,它會(huì)手找到父級(jí)元素 <div> 并激活它的能力,慢慢消失,隱藏起來(lái)。

$(document).ready(function(){$(".pane .delete").click(function(){	  $(this).parents(".pane").animate({ opacity: "hide" }, "slow");	});});

3 連續(xù)過(guò)渡效果

讓我們來(lái)看看jQuery連貫性的威力吧。只需要幾行代碼,我能讓這個(gè)方塊漸變+縮放比例地飛來(lái)飛去(view demo)

Line 1: 當(dāng) <a> 被點(diǎn)擊
Line 2: 激活 <div id=”box”> 的不透明度(opacity)=0.1,直到值達(dá)到400px,速度達(dá)到1200px/ms
Line 3: 當(dāng)opacity=0.4, top=160px,height=20,width=20,以”slow”顯示
Line 4: 當(dāng)opacity=1, left=0, height=100, width=100,也以”slow”顯示
Line 5: 當(dāng)opacity=1, left=0, height=100, width=100, 也以”slow”顯示
Line 6: 當(dāng)top=0, 以”fast”顯示
Line 7: 然后,以常速上滑 (default speed = “normal”)
Line 8: 然后以”slow”下滑
Line 9:返回失效會(huì)阻止瀏覽器跳向鏈接錨點(diǎn)

$(document).ready(function(){$(".run").click(function(){$("#box").animate({opacity: "0.1", left: "+=400"}, 1200)	  .animate({opacity: "0.4", top: "+=160", height: "20", width: "20"}, "slow")	  .animate({opacity: "1", left: "0", height: "100", width: "100"}, "slow")	  .animate({top: "0"}, "fast")	  .slideUp()	  .slideDown("slow")	  return false;});});

4a. 可折疊的模式 #1

這是第一個(gè)可折疊的樣式, (view demo)

第一行將向<div> 內(nèi)的第一個(gè)<H3> 添加一個(gè)CSS class為”active”的值。 第二行剛是隱藏<div>內(nèi)非第一個(gè)< p >的內(nèi)容。

當(dāng) <h3> 被點(diǎn)擊時(shí),當(dāng)前<p>下拉,而原先下拉的<p> 上提。

$(document).ready(function(){$(".accordion h3:first").addClass("active");	$(".accordion p:not(:first)").hide();$(".accordion h3").click(function(){$(this).next("p").slideToggle("slow")	  .siblings("p:visible").slideUp("slow");	  $(this).toggleClass("active");	  $(this).siblings("h3").removeClass("active");});});

4b. 可折疊模式 #2

這個(gè)實(shí)例與#1非常類似,不過(guò),它會(huì)讓指定的面板像默認(rèn)面板一樣打開(kāi)(view demo)

在CSS樣式表中,設(shè)置.accordion pdisplay:none。現(xiàn)在,如果你像默認(rèn)打開(kāi)的樣式一樣,打開(kāi)第三個(gè)面板,你可以寫(xiě)$(".accordion2 p").eq(2).show(); (eq = equal)來(lái)實(shí)現(xiàn)它,需要注意的是起始點(diǎn)是”0″,而不是”1″,所以,第三個(gè)相應(yīng)的是”2″,而不是”3″。

$(document).ready(function(){$(".accordion2 h3").eq(2).addClass("active");	$(".accordion2 p").eq(2).show();$(".accordion2 h3").click(function(){	  $(this).next("p").slideToggle("slow")	  .siblings("p:visible").slideUp("slow");	  $(this).toggleClass("active");	  $(this).siblings("h3").removeClass("active");	});});

5a. 鼠標(biāo)經(jīng)過(guò)激活效果 #1

這個(gè)將會(huì)實(shí)現(xiàn)一個(gè)非常漂亮的,當(dāng)鼠標(biāo)經(jīng)過(guò)時(shí)出現(xiàn)漸變出現(xiàn)的效果 (view demo)

當(dāng)鼠標(biāo)經(jīng)過(guò)菜單時(shí),它會(huì)尋找緊接著的<em>,并在上方激活它的不透明度。

$(document).ready(function(){$(".menu a").hover(function() {	  $(this).next("em").animate({opacity: "show", top: "-75"}, "slow");	}, function() {	  $(this).next("em").animate({opacity: "hide", top: "-85"}, "fast");	});});

5b. 鼠標(biāo)經(jīng)過(guò)激活 #2

這個(gè)實(shí)例會(huì)顯示菜單中鏈接的title 屬性attribute,讓其以變數(shù)方式存在,并添加<em>標(biāo)簽 (view demo)

第一行會(huì)添加一個(gè)空的<em>到菜單的<a>元素。

當(dāng)鼠標(biāo)經(jīng)過(guò)菜單鏈接時(shí),它會(huì)顯示title的屬性,讓它以”hoverText(隱藏)”的形式顯示,并使<em>中的文字顯示隱藏文本的值。

$(document).ready(function(){$(".menu2 a").append("<em></em>");$(".menu2 a").hover(function() {	  $(this).find("em").animate({opacity: "show", top: "-75"}, "slow");	  var hoverText = $(this).attr("title");	  $(this).find("em").text(hoverText);	}, function() {	  $(this).find("em").animate({opacity: "hide", top: "-85"}, "fast");	});});

6. 整塊可點(diǎn)擊性效果

這個(gè)實(shí)例將會(huì)教你如何實(shí)現(xiàn)內(nèi)容中元素可點(diǎn)擊性效果,Best Web Gallery的側(cè)邊欄Tab就顯示這樣的效果 (view demo)

如果你想讓class=”pane-list”的<ul>內(nèi)的 <li> 可點(diǎn)擊(整塊),你可以向 “.pane-list li”指派一個(gè)函數(shù),使它被點(diǎn)擊時(shí),函數(shù)找到 <a>元素,重定向到它的href屬性值。

$(document).ready(function(){$(".pane-list li").click(function(){	  window.location=$(this).find("a").attr("href"); return false;	});});

7. 可收縮面板

讓我們組合一下上面的實(shí)例,創(chuàng)造一給可收縮的面板(像Gmai收件箱面板l)。作者還在Web Designer Wall 的評(píng)論列表Next2Friends里應(yīng)用這個(gè)(view demo)

First line: 隱藏<div>里第一個(gè)元素以后的元素
Second line: 隱藏所有第5個(gè)<li>后面的元素
Third part: 當(dāng)<p>被點(diǎn)擊里,顯示/隱藏<div >
Fourth part: 當(dāng)<a > 被點(diǎn)擊時(shí),上提所有<div>的元素
Fifth part: 當(dāng)<a> 被點(diǎn)擊,隱藏它,并顯示<a>,并下拉第5個(gè)<li>以后的元素
Sixth part: 當(dāng)<a> 被點(diǎn)擊時(shí),隱藏它,并顯示<a>,并上提第5個(gè) <li>以后的元素

$(document).ready(function(){//hide message_body after the first one	$(".message_list .message_body:gt(0)").hide();//hide message li after the 5th	$(".message_list li:gt(4)").hide();//toggle message_body	$(".message_head").click(function(){	  $(this).next(".message_body").slideToggle(500)	  return false;	});//collapse all messages	$(".collpase_all_message").click(function(){	  $(".message_body").slideUp(500)	  return false;	});//show all messages	$(".show_all_message").click(function(){	  $(this).hide()	  $(".show_recent_only").show()	  $(".message_list li:gt(4)").slideDown()	  return false;	});//show recent messages only	$(".show_recent_only").click(function(){	  $(this).hide()	  $(".show_all_message").show()	  $(".message_list li:gt(4)").slideUp()	  return false;	});});

8. 模仿WordPress后臺(tái)評(píng)論管理面板

我想你可能見(jiàn)過(guò)最多次這個(gè)效果是在Wordpress后臺(tái)的評(píng)論管理面板。那好,讓我們來(lái)用jQuery來(lái)模仿它的效果。為了實(shí)現(xiàn)背景顏色,你需要包含Color Animations這個(gè)插件(view demo)

First line: 向<div> 添加 “alt” class
Second part: 當(dāng)<a>被點(diǎn)擊,激活<div >的不透明度
Third part: 當(dāng)<a >被點(diǎn)擊, 首先讓<div >顯示黃色,然后變?yōu)榘咨?,并添加類(addClass)”spam”
Fourth part: 當(dāng)<a>被點(diǎn)擊,首先讓<div >顯示綠色,然后變?yōu)榘咨⒁瞥悾╮emoveClass)”spam”
Fifth part: 當(dāng)<a>被點(diǎn)擊,激活背景色為red并使其opacity =”hide”

//don't forget to include the Color Animations plugin//<script type="text/javascript" src="jquery.color.js"></script>$(document).ready(function(){$(".pane:even").addClass("alt");$(".pane .btn-delete").click(function(){	  alert("This comment will be deleted!");$(this).parents(".pane").animate({ backgroundColor: "#fbc7c7" }, "fast")	  .animate({ opacity: "hide" }, "slow")	  return false;	});$(".pane .btn-unapprove").click(function(){	  $(this).parents(".pane").animate({ backgroundColor: "#fff568" }, "fast")	  .animate({ backgroundColor: "#ffffff" }, "slow")	  .addClass("spam")	  return false;	});$(".pane .btn-approve").click(function(){	  $(this).parents(".pane").animate({ backgroundColor: "#dafda5" }, "fast")	  .animate({ backgroundColor: "#ffffff" }, "slow")	  .removeClass("spam")	  return false;	});$(".pane .btn-spam").click(function(){	  $(this).parents(".pane").animate({ backgroundColor: "#fbc7c7" }, "fast")	  .animate({ opacity: "hide" }, "slow")	  return false;	});});

9. 輪換圖片展欄

如果你有一個(gè)項(xiàng)目需要顯示多個(gè)圖片,并且你不希望鏈向另一個(gè)頁(yè)面,那么你可以在當(dāng)前面加載目標(biāo)鏈接的JPG(view demo)

首先,添加一個(gè)<em>到H2標(biāo)簽。

當(dāng)<p>內(nèi)的元素被點(diǎn)擊:
- 以可視的形式顯示href屬性的”largePath”路徑
- 以可視的形式顯示title 屬性的”largeAlt”
- 代換<img id=”largeImg”>的scr屬性內(nèi)可視的”largePath”路徑,并代換alt屬性內(nèi)可視的”largeAlt”
- 設(shè)置em內(nèi)的內(nèi)容(h2內(nèi)) 為可視的largeAlt

$(document).ready(function(){$("h2").append('<em></em>')$(".thumbs a").click(function(){var largePath = $(this).attr("href");	  var largeAlt = $(this).attr("title");$("#largeImg").attr({ src: largePath, alt: largeAlt });$("h2 em").html(" (" + largeAlt + ")"); return false;	});});

10. 個(gè)性化不同的鏈接樣式

在現(xiàn)代化的瀏覽器中,個(gè)性化不同的鏈接是非常容易的事,比如想讓.pdf文件顯示特殊的樣式,你只需要添加上簡(jiǎn)單的CSS規(guī)則:a[href $='.pdf'] { ... }就可以實(shí)現(xiàn),但不幸的是IE6并不支持這個(gè)。如果想實(shí)現(xiàn)這個(gè),你可以利用jQuery (view demo)

前三行代碼必需是連續(xù)的,它只是一個(gè)<a>的href屬性中的一個(gè)CSS class。

第二部分將會(huì)獲取所有href中沒(méi)有”http://www.webdesignerwall.com” 和/或沒(méi)有”#”的< a>元素,并添加”external” class和target= “_blank”。

$(document).ready(function(){$("a[@href$=pdf]").addClass("pdf");$("a[@href$=zip]").addClass("zip");$("a[@href$=psd]").addClass("psd");$("a:not([@href*=http://www.webdesignerwall.com])").not("[href^=#]")	  .addClass("external")	  .attr({ target: "_blank" });});轉(zhuǎn)自:http://www.629d.com/a/201002/159.html
樹(shù)型菜單的實(shí)現(xiàn):http://www.open-lib.com/html/Type/194-1.html
21個(gè)漂亮的Ajax+Table實(shí)例
http://hi.baidu.com/freezesoul/blog/item/ca69a818f806610435fa411a.html
表格樹(shù)的實(shí)現(xiàn):http://blog.sina.com.cn/s/blog_3efe6ef10100fcv2.html
實(shí)例下載:http://www.javaeye.com/topic/435802
一個(gè)頁(yè)面上彈出的層太多了,就容易亂,這時(shí)就要用到浮動(dòng)定位層了。具體使用方法請(qǐng)參看:
http://www.cnblogs.com/wjfluisfigo/archive/2009/01/15/1359309.html
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
閱讀 jQuery 源碼的18個(gè)驚喜
Web設(shè)計(jì)師值得收藏的10個(gè)jQuery特效(1)
A Simple jQuery Slideshow
!!!!!!!譯 HTML和CSS高級(jí)指南之六——jQuery
【Jquery 】動(dòng)態(tài)添加、刪除class樣式
jquery基礎(chǔ)用法總結(jié)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服