abstrait:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,&
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js"></script> <script type="text/javascript"> // $(document).ready(function(){ // // 開始寫 jQuery 代碼... // // }); // //簡(jiǎn)潔寫法 // 選擇器 // $("p") 選擇所有P元素 // $("#test") 選擇id等于test的元素 // $(".test") 選擇class=test的元素 // $("*") 選取所有元素 // $(this) 選取當(dāng)前HMLT元素 // $("p.intro") 選取class為intro的p元素 // $("p:first") 選取第一個(gè)p元素 // $("ul li:first") 選取第一個(gè)ul元素的第一個(gè)li元素 // $("ul li:first-child") 選取每個(gè)ul元素的第一個(gè)li元素 // $("[href]") 選取帶有href屬性的元素 // $("a[target='_blank']") 選取書友target值等于_blank的a元素 // $("a[target!='_blank']") 選取所有target屬性不等于blank的a元素 // $(":button") 選取所有type=button的元素和button元素 // $("tr:even") 選取偶數(shù)位置的tr元素 // $("tr:odd") 選取奇數(shù)位置的tr元素 $(function(){ //防止dom未加載,jQuery代碼就開始運(yùn)行,導(dǎo)致運(yùn)行失敗。 // 開始寫 jQuery 代碼... $('#tap1').click(function(){ //選擇div元素/ $('div').hide();//元素隱藏 }) }); </script> <style media="screen" type="text/css"> div{background: #e2c712 ;width: 100px;height: 100px} </style> <title>Document</title> </head> <body> <div class="" id="tap1"> </div> </body> </html>
在其他地方看到說 $(document).ready()簡(jiǎn)寫成
$(function(){ // 開始寫 jQuery 代碼...
}); 也可以,請(qǐng)問是對(duì)的么。
Professeur correcteur:查無此人Temps de correction:2019-01-18 09:11:11
Résumé du professeur:作業(yè)完成的不錯(cuò)。$(function(){ }); 這樣是可以的,這個(gè)是jQuery的,繼續(xù)加油