1. 程式人生 > 其它 >jQuery自定義動畫animate

jQuery自定義動畫animate

程式碼示例:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>24-jQuery自定義動畫效果animate</title>
        <style type="text/css">
            div {
                height: 200px;
                width: 200px;
                background-color:
pink; position: relative; left: 1000px; top: 2600px; } </style> </head> <body> <button>動起來</button> <div></div> </body> <script src="jquery-3.6.0.js" type="text/javascript"
charset="utf-8"></script> <script type="text/javascript"> $(function() { $("button").click(function() { $("div").animate({ left: 500, top: 300, opacity: 0.4, width: 500 },
500) }) }) </script> </html>