abstrak:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JQ動(dòng)畫效果</title> <script type="text/javascript" src="jquer
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JQ動(dòng)畫效果</title> <script type="text/javascript" src="jquery-3.3.1.js"></script> <style type="text/css"> .box{position: absolute;width: 100px;height: 200px;background: red} </style> </head> <body> <script type="text/javascript"> // JQuery中我們使用animate()方法創(chuàng)建自定義的動(dòng)畫 // 語法:$(selector).animate({params},speed,fn); // 必需的 params 參數(shù)定義形成動(dòng)畫的css屬性 // 可選的 speed 參數(shù)規(guī)定效果的時(shí)長。它可以取以下值:"slow,fast"或者毫秒 // 可選的 fn是動(dòng)畫完成后所執(zhí)行的函數(shù) // stop()方法用于停止動(dòng)畫或者效果,在它們完成之前 該方法適用于所有JQuery 效果函數(shù),包括滑動(dòng),淡入淡出和自定義動(dòng)畫 // 語法:$(selector).stop(stopAll,goToEnd) // 可選參數(shù) stopAll 規(guī)定是否應(yīng)該清除動(dòng)畫隊(duì)列。默認(rèn)是false 僅停止活動(dòng)的動(dòng)畫,允許任何排入隊(duì)列的動(dòng)畫向后執(zhí)行 // 可選參數(shù)goToEnd 規(guī)定是否立即完成當(dāng)前動(dòng)畫。默認(rèn)是false // 默認(rèn)情況下 stop() 會(huì)清除在被選元素上指定的當(dāng)前動(dòng)畫 $(function(){ $('.btn1').click(function(){ $('p').animate({fontSize:'30px',color:'red'},1500) }) $('.btn2').click(function(){ $('.box').animate({ left:'200px', background:'blue', opacity:0.6, width:'400px', height:'toggle' },1500) }) $('#right').click(function(){ $('.box').animate({left:'+=300px'},3000) $('.box').animate({fontSize:'+=10px'},800) }) $('#stop').click(function(){ $('.box').stop(true,true) }) }) </script> <button>點(diǎn)擊字體放大</button> <button>點(diǎn)擊字體放大</button> <button id="stop">停止</button> <button id="right">右移</button> <p>JQuery中我們使用animate()方法創(chuàng)建自定義的動(dòng)畫</p> <div>PHP中文網(wǎng)</div> </body> </html>
Guru membetulkan:滅絕師太Masa pembetulan:2018-10-29 17:31:58
Rumusan guru:美滋滋,棒