jquery類操作
阿新 • • 發佈:2020-10-11
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <script src="jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> //入口函式 $(document).ready(function() { var jqInput = $("input"); var jqDiv = $("div"); jqInput.click(function() { jqDiv.toggleClass("toggle"); }) }); </script> <style type="text/css"> div { height: 100px; width: 100px; background-color: aqua; margin: 10px; } .toggle { background-color: red; } </style> </head> <body> <input type="button" name="" id="" value="切換" /> <div id=""> </div> </body> </html>