abstract:<!DOCTYPE html> <html> <head> <title>jQuery的animate()方法來自定義動(dòng)畫</title> <script type="text/javascript" src="jquery-3.3.1.min.js">
<!DOCTYPE html> <html> <head> <title>jQuery的animate()方法來自定義動(dòng)畫</title> <script type="text/javascript" src="jquery-3.3.1.min.js"></script> <style type="text/css"> div{width: 200px;height: 200px;background: red;position: absolute;} </style> <script type="text/javascript"> //在jQuery中用 animate()方法來自定義動(dòng)畫 //語法:$(selector).animate({params},speed,fn); //params參數(shù)定義形成動(dòng)畫的css屬性是必需的 $(document).ready(function () { $('.bt1').click(function () { $('p').animate({fontSize:'40px'},1500); //屬性名稱中有-的,全部寫成駝峰寫法 }) $('.bt2').click(function () { $('div').animate({left:'200px',top:'200px',background:'blue'},1500) }) }) </script> </head> <body> <button class="bt1">點(diǎn)擊字體放大</button> <p>444444444點(diǎn)擊字體放大44444444444</p> <button class="bt2">點(diǎn)擊移動(dòng)DIV</button> <div></div> </body> </html>