jQuery實(shí)現(xiàn)移動 和 漸變特效的點(diǎn)擊事件
先看代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="js/jquery.js"></script>
</head>
<style>
body{font-family: "微軟雅黑";width: 980px; margin: 0 auto; text-align: center;}
.box{
width: 300px;
height: 300px;
background: green;
border: 1px solid #e6e6e6;
margintop: 50px;
line-height: 200px;
position: absolute;
}
button{
border: none;
background: green;
width: 100px;
height: 50px;
line-height: 50px;
color: #fff;
font-size: 16px;
margin-top: 50px;
}
</style>
<body>
<button>點(diǎn)擊開始動畫</button>
<div class="box" ></div>
<script>
$(document).ready(function(){
$("button").click(function(){
var div=$(".box");
div.animate({height:'200px',opacity:'0.4'},"slow");
div.animate({width:'200px',opacity:'0.8'},"slow");
div.animate({height:'100px',opacity:'0.4'},"slow");
div.animate({width:'100px',opacity:'0.8'},"slow");
div.animate({right:'100px',opacity:'0.8'},"slow");
div.animate({bottom:'100px',opacity:'0.8'},"slow");
div.animate({left:'100px',opacity:'0.8'},"slow");
div.animate({top:'100px',opacity:'0.8'},"slow");
});
});
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
var div=$(".box");
div.animate({height:'300px',opacity:'0.4'},"slow");
div.animate({width:'300px',opacity:'0.8'},"slow");
div.animate({height:'100px',opacity:'0.4'},"slow");
div.animate({width:'100px',opacity:'0.8'},"slow");
});
});
});
</script>
</body>
</html>
.animate 事件,是這個(gè) 里面的新的東西。解釋起來就是 使div 塊兒 變得有靈魂 可以移動。
Tips:
1、click 事件的 點(diǎn)擊節(jié)點(diǎn)的選擇
2、通過 var div=$(".box") 來選擇需要控制的 css 屬性
剩下的就要靠 自己去敲代碼,看效果 去理解其中的 意思。
- jquery無法為動態(tài)生成的元素添加點(diǎn)擊事件的解決方法(推薦)
- jQuery添加options點(diǎn)擊事件并傳值實(shí)例代碼
- jquery 觸發(fā)a鏈接點(diǎn)擊事件解決方案
- jQuery實(shí)現(xiàn)當(dāng)按下回車鍵時(shí)綁定點(diǎn)擊事件
- jQuery實(shí)現(xiàn)按鈕只點(diǎn)擊一次后就取消點(diǎn)擊事件綁定的方法
- jquery中交替點(diǎn)擊事件的實(shí)現(xiàn)代碼
- jquery實(shí)現(xiàn)點(diǎn)擊label的同時(shí)觸發(fā)文本框點(diǎn)擊事件的方法
- jQuery中slideUp 和 slideDown 的點(diǎn)擊事件
- jQuery實(shí)現(xiàn)點(diǎn)擊行選中或取消CheckBox的方法
- jQuery移除或禁用html元素點(diǎn)擊事件常用方法小結(jié)
相關(guān)文章
jQuery Mobile操作HTML5的常用函數(shù)總結(jié)
jQuery Mobile是針對移動端開發(fā)的JavaScript框架,正如其名基于jQuery庫,jQuery Mobile主要被用來操作HTML5設(shè)計(jì)頁面UI,下面就來看一下jQuery Mobile操作HTML5的常用函數(shù)總結(jié):2016-05-05
使用jQuery Ajax 請求webservice來實(shí)現(xiàn)更簡練的Ajax
以往我們在做ajax時(shí),都要借助于一般處理程序(.ashx)或web服務(wù)(.asmx),并且每一個(gè)請求都要建一個(gè)這樣的文件,非常麻煩,下面我們甩掉ashx和asmx來使用jQuery Ajax 請求webservice來實(shí)現(xiàn)更簡練的Ajax,需要的朋友參考下2016-08-08
淺談$(''div a'') 與$(''div>a'')的區(qū)別
下面小編就為大家?guī)硪黄獪\談$('div a') 與$('div>a')的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-07-07
實(shí)現(xiàn)easyui的datagrid導(dǎo)出為excel的示例代碼
下面小編就為大家?guī)硪黄獙?shí)現(xiàn)easyui的datagrid導(dǎo)出為excel的示例代碼。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11
老生常談jquery id選擇器和class選擇器的區(qū)別
下面小編就為大家?guī)硪黄仙U刯query id選擇器和class選擇器的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02
jQuery實(shí)現(xiàn)B2B網(wǎng)站后臺管理系統(tǒng)側(cè)導(dǎo)航
這篇文章主要介紹了jQuery實(shí)現(xiàn)B2B網(wǎng)站后臺管理系統(tǒng)側(cè)導(dǎo)航,文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下2020-07-07
jQuery學(xué)習(xí)筆記——jqGrid的使用記錄(實(shí)現(xiàn)分頁、搜索功能)
這篇文章主要介紹了jQuery學(xué)習(xí)筆記——jqGrid的使用記錄(實(shí)現(xiàn)分頁、搜索功能),想要學(xué)習(xí)jQuery的可以了解一下。2016-11-11

