abstrak:?jiǎn)螕綦[藏按鈕,矩形將被隱藏起來<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>隱藏矩形</title> <script type="text/javascript" sr
單擊隱藏按鈕,矩形將被隱藏起來
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>隱藏矩形</title> <script type="text/javascript" src="jquery-3.3.1.js"></script> <style type="text/css"> div{ width: 200px; height: 200px; background: pink; border: 1px solid #ccc; } </style> </head> <body> <div></div> <button>隱藏</button> <script type="text/javascript"> //文本就緒 $(document).ready(function(){ $('button').click(function(){ $('div').hide() }) }) </script> </body> </html>
總結(jié):
1、需要在頭文件中引入jQuery文件
2、需要在變成功能之前寫文檔就緒函數(shù):$(document).ready(function(){
內(nèi)容}),然后再在內(nèi)容部分寫功能代碼
Guru membetulkan:韋小寶Masa pembetulan:2019-01-21 09:06:38
Rumusan guru:寫的很不錯(cuò) 文檔就緒函數(shù)還有一種簡(jiǎn)寫的方式 $(function(){ }) 這樣也是可以的