abstrait:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JQ動畫效果</title> <script type="text/javascript" src="jquer
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JQ動畫效果</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)建自定義的動畫 // 語法:$(selector).animate({params},speed,fn); // 必需的 params 參數定義形成動畫的css屬性 // 可選的 speed 參數規(guī)定效果的時長。它可以取以下值:"slow,fast"或者毫秒 // 可選的 fn是動畫完成后所執(zhí)行的函數 // stop()方法用于停止動畫或者效果,在它們完成之前 該方法適用于所有JQuery 效果函數,包括滑動,淡入淡出和自定義動畫 // 語法:$(selector).stop(stopAll,goToEnd) // 可選參數 stopAll 規(guī)定是否應該清除動畫隊列。默認是false 僅停止活動的動畫,允許任何排入隊列的動畫向后執(zhí)行 // 可選參數goToEnd 規(guī)定是否立即完成當前動畫。默認是false // 默認情況下 stop() 會清除在被選元素上指定的當前動畫 $(function(){ $('.btn1').click(function(){ $('p').animate({fontSize:'30px',color:'red'},1500) }) $('.btn2').click(function(){ $('.box').animate({ left:'200px', background:'blue', opacity:0.6, height:'toggle', width:'400px' },1500) }) }) </script> <button>點擊字體放大</button> <button>點擊字體放大</button> <p>JQuery中我們使用animate()方法創(chuàng)建自定義的動畫</p> <div></div> </body> </html>