jquery可以處理頁(yè)面動(dòng)作,作出很絢麗的動(dòng)畫特效

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比甘井子網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式甘井子網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋甘井子地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。
可以跳轉(zhuǎn)頁(yè)面,調(diào)用后臺(tái)數(shù)據(jù)接口
獲取頁(yè)面數(shù)據(jù),對(duì)頁(yè)面進(jìn)行數(shù)據(jù)驗(yàn)證
可以擴(kuò)展插件
本文以實(shí)例形式詳細(xì)講述了jQuery動(dòng)畫特效的實(shí)現(xiàn)方法。分享給大家供大家參考之用。具體方法如下:
1.自制折疊內(nèi)容塊
內(nèi)容塊如下:
div
class="module"
div
class="caption"
span標(biāo)題/span
img
src="rollup.gif"
alt="rollup"
title="rolls
up
this
module"/
/div
div
class="body"
近日,《體壇周報(bào)》記者馬德興在接受天津體育頻道《體壇新視野》節(jié)目采訪時(shí)表示自己對(duì)恒大[微博]的情況比較擔(dān)憂,恒大統(tǒng)治力比上賽季下降了很多,恒大外援存在位置重疊的問題,客場(chǎng)不輸給西悉尼流浪者就是一個(gè)可以接受的結(jié)果。該節(jié)目稱恒大聯(lián)賽3連勝勝之不武,恒大的惹不起不過爾爾,恒大失去了對(duì)其它球隊(duì)壓倒性的優(yōu)勢(shì),能力下降是恒大霸主地位有所動(dòng)搖的根源所在。
/div
/div
給img元素綁定點(diǎn)擊事件。
$(function()
{
$('div.caption
img').click(function
()
{
//先找到img的父級(jí)元素,再找該父級(jí)元素的子元素
var
$body
=
$(this).closest('div.module').find('div.body');
if
($body.is(':hidden'))
{
$body.show();
}
else
{
$body.hide();
}
});
});
運(yùn)行效果如下圖所示:
切換元素的顯示狀態(tài),還可以用toggle方法。
$(function()
{
$('div.caption
img').click(function
()
{
$(this).closest('div.module').find('div.body').toggle();
});
});
以上是沒有動(dòng)畫效果的,有時(shí)候感覺會(huì)很唐突。實(shí)際上,show,hide,toggle方法都可以有動(dòng)畫效果。比如:
$(function()
{
$('div.caption
img').click(function
()
{
$(this).closest('div.module').find('div.body').toggle('slow');
});
});
又比如:
$(function()
{
$('div.caption
img').click(function
()
{
$(this).closest('div.module').find('div.body').toggle('slow',
function()
{
$(this).closest('div.module').toggleClass('rolledup',
$(this).is(':hidden'))
});
});
});
2.使元素淡入淡出
fadeIn(speed,
callback)
fadeOut(speed,
callback)
fadeTo(speed,
opacity,
callback)
3.上下滑動(dòng)元素
slideDown(speed,
callback)
slideUp(speed,
callback)
slideToggle(speed,
callback)
4.停止動(dòng)畫
stop(clearQueue,
gotoEnd)
5.創(chuàng)建自定義動(dòng)畫
animate(properties,
duration,
easing,
callback)
$('.classname').animate({opacity:'toggle'},'slow')
如果寫一個(gè)擴(kuò)展函數(shù)。
$.fn.fadeToggle
=
function(speed){
return
this.animate({opacity:'toggle'},'slow');
}
6.自定義縮放動(dòng)畫
$('.classname').each(function(){
$(this).animate({
width:
$(this).width()
*
2,
height:
$(this).height()
*
2
});
});
7.自定義掉落動(dòng)畫
$('.classname').each(function(){
$(this)
.css("position","relative")
.animate({
opacity:
0,
top:
$(window).height()
-
$(this).height()
-
$(this).position().top
},'slow',function(){
$(this).hide();
})
});
8.自定義消散動(dòng)畫
$('.classname').each(function(){
var
position
=
$(this).position();
$(this)
.css({
position:
'absolute',
top:
position.top,
left:position.left
})
.animate({
opacity:
'hide',
width:
$(this).width()*5,
height:
$(this).height()*5
top:
position.top
-
($(this).height()
*
5
/
2),
left:
position.left
-
($(this).width()
*
5
/2)
},'normal');
});
9.隊(duì)列中的動(dòng)畫
//動(dòng)畫插入隊(duì)列
$('img').queue('chain',
function(){});
$('img').queue('chain',
function(){});
$('img').queue('chain',
function(){});
$('img').queue('chain',
function(){});
$('button').click(function(){
$('img').dequeue('chain');
//刪除隊(duì)列中的動(dòng)畫
})
cleaeQueue(name)//刪除所有未執(zhí)行的隊(duì)列中的動(dòng)畫
delay(duration,
name)//為隊(duì)列中所有未執(zhí)行的動(dòng)畫添加延遲
相信本文所述對(duì)大家的jQuery程序設(shè)計(jì)有一定的借鑒價(jià)值。
采用Jquery實(shí)現(xiàn)的列表數(shù)據(jù)動(dòng)態(tài)更新效果,更新的數(shù)據(jù)可以是ajax請(qǐng)求的數(shù)據(jù)。
CSS:
.main
{
width:
100%;
margin-top:
100px;
text-align:
center;
font-size:
12.5px;
}
th,
td
{
border:
1px
solid
#ccc;
line-height:
40px;
padding-left:
5px;
}
.item:hover
{
background-color:
#efefef;
}
.item:nth-child(2n)
{
background-color:
#efefef;
}
.ListView
{
width:
600px;
overflow:
hidden;
margin:
auto;
padding:
10px;
height:372px;
border:
1px
solid
#dddddd;
}
.ListView
.c
{
width:
1200px;
margin:
auto;
border-collapse:
collapse;
}
.Item
{
border-bottom:
1px
dashed
#dddddd;
padding:
10px
10px
0;
overflow:
hidden;
margin-left:600px;
}
.Item
span
{
float:
left;
text-align:
left;
}
.Item
span:first-child
{
color:
#6AA8E8;
}
.Item
span:last-child
{
text-align:
center;
}
HTML
div
class="main"
div
class="ListView"
div
class="c"
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
div
class="Item"
spantest/span
span男/0/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div
/div
/div
/div
p
style="text-align:center;"a
href="javascript:void(0);"
onClick="ListView.Update();"刷新數(shù)據(jù)/a/p
JS
script
type="text/javascript"
src="/js/jquery-1.8.0.min.js"/script
script
type="text/javascript"
$(function(){
ListView.Init();
});
var
ListView={
Init:function(){
$(".Item
span").css("width",$(".ListView").width()/4+"px");
for(var
i=0;i$(".Item").length;i++){
var
target=$(".Item")[i];
$(target).animate({marginLeft:"0px"},300+i*100);
}
},
Update:function(){
$(".ListView
.c
.Item").remove();
for(var
i=0;i10;i++){
var
newItem=$("div
class=\"Item\"
spantest/span
span男/"+i+"/span
span四川省,成都市,錦江區(qū)/span
span詳細(xì)說明/span
/div");
$(newItem).find("span").css("width",$(".ListView").width()/4+"px");
$(".ListView
.c").append(newItem);
$(newItem).animate({marginLeft:"0px"},300+i*100);
}
}
}
/script
附上演示效果
效果是不是非常棒呢,接下來我們?cè)賮砜纯雌俨剂鞯膶?shí)現(xiàn)思路和js控制動(dòng)態(tài)加載的代碼
下面的代碼主要是控制滾動(dòng)條下拉時(shí)的加載事件的
在下面代碼說明出,寫上你的操作即可,無論是加載圖片還是加載記錄數(shù)據(jù)
都可以
別忘了引用jquery類庫(kù)
$(window).scroll(function
()
{
var
scrollTop
=
$(this).scrollTop();
var
scrollHeight
=
$(document).height();
var
windowHeight
=
$(this).height();
if
(scrollTop
+
windowHeight
==
scrollHeight)
{
//此處是滾動(dòng)條到底部時(shí)候觸發(fā)的事件,在這里寫要加載的數(shù)據(jù),或者是拉動(dòng)滾動(dòng)條的操作
//var
page
=
Number($("#redgiftNextPage").attr('currentpage'))
+
1;
//redgiftList(page);
//$("#redgiftNextPage").attr('currentpage',
page
+
1);
}
});
解析:
判斷滾動(dòng)條到底部,需要用到DOM的三個(gè)屬性值,即scrollTop、clientHeight、scrollHeight。
scrollTop為滾動(dòng)條在Y軸上的滾動(dòng)距離。
clientHeight為內(nèi)容可視區(qū)域的高度。
scrollHeight為內(nèi)容可視區(qū)域的高度加上溢出(滾動(dòng))的距離。
從這個(gè)三個(gè)屬性的介紹就可以看出來,滾動(dòng)條到底部的條件即為scrollTop
+
clientHeight
==
scrollHeight。(兼容不同的瀏覽器)。
1.flavr—超級(jí)漂亮的jQuery扁平彈出對(duì)話框 ? ??
2.輕量級(jí)觸摸響應(yīng)滑塊插件JQuery lightSlider ? ? ?
3.帶37種3D動(dòng)畫特效的跨瀏覽器CSS3動(dòng)畫框架 ? ? ??
4.jquery整屏滾動(dòng)插件Scrollify ? ? ? ?
5.jquery旋轉(zhuǎn)木馬插件SLICK ? ? ? ??
6.jquery文字動(dòng)畫插件LetterFX ? ? ? ? ?
7.jquery文本翻轉(zhuǎn)插件Wodry.js ? ? ??
8.jquery通知插件toastr ? ? ??
9.jQuery滾動(dòng)執(zhí)行動(dòng)畫插件FadeThis ? ? ?
10.jquery表單驗(yàn)證插件Bootstrap Validator ? ? ??
11.jCountdown倒計(jì)時(shí)插件jQuery ? ? ? ? ??
12.iCheck不一樣的checkbok ? ? ? ??
13.Owl Carousel強(qiáng)大的響應(yīng)式j(luò)Query焦點(diǎn)圖輪播插件 ??
14.magic-帶64種動(dòng)畫效果的CSS3動(dòng)畫庫(kù) ? ??
15.jQuery實(shí)時(shí)搜索插件-HideSeek ? ? ??
16.bootstrap modal對(duì)話框 ? ? ? ? ? ??
17.一款模擬CSS3動(dòng)畫的js插件-move.js ? ? ? ? ? ???
18.可替代CSS3 transition和transform的jQuery插件 ? ? ? ? ?
19.基于bootstrap的jQuery多功能模態(tài)對(duì)話框插件
20.帶CSS3過渡效果的js模態(tài)窗口插件 ? ? ???
21.支持移動(dòng)觸摸設(shè)備的簡(jiǎn)潔js幻燈片插件
22.jQuery輕量級(jí)響應(yīng)式扁平風(fēng)格tabs選項(xiàng)卡插件
23.jQuery輕量級(jí)響應(yīng)式Tooltip插件
24.jQuery簡(jiǎn)單且功能強(qiáng)大的圖片剪裁插件
25.帶CSS3動(dòng)畫過渡效果的jQuery模態(tài)窗口插件
26.中國(guó)省市區(qū)地址三級(jí)聯(lián)動(dòng)jQuery插件
27.移動(dòng)端優(yōu)先且支持jQuery和Zepto的模態(tài)對(duì)話框插件
28.jQuery簡(jiǎn)單實(shí)用的tooltip插件
29.帶CSS3過渡動(dòng)畫效果的jQuery Tabs選項(xiàng)卡插件
30.x0popup-純js彈出對(duì)話框插件
31.WOW.js-元素在頁(yè)面滾動(dòng)時(shí)展示CSS3動(dòng)畫JS插件
32.Windows8樣式的消息提示框jQuery插件
33.jQuery星級(jí)評(píng)分插件
34.fsBanner-實(shí)用的網(wǎng)站響應(yīng)式Banner手風(fēng)琴插件
35.draggabilly-功能強(qiáng)大的拖動(dòng)拖拽元素插件
36.驗(yàn)證插件vali.js
37.響應(yīng)式j(luò)Query圖片放大鏡插件magnificent.js
38.可快速生成各種陰影效果的jQuery插件
39.基于jquery的非常逼真的全屏下雪效果
40.純文本Loading加載指示器特效
網(wǎng)頁(yè)題目:jquery特效大全,JQuery特效
網(wǎng)址分享:http://chinadenli.net/article25/dsshdci.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、Google、網(wǎng)站收錄、外貿(mào)建站、小程序開發(fā)、網(wǎng)頁(yè)設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)