abstrak:通過對JQuery基礎(chǔ)語法練習(xí),簡單了解了JQuery控制css屬性的用法,并學(xué)會了通過$("[id=div1]")的方法,用JQuery同時控制所有ID相同的div。也祝各位老師節(jié)日快樂,christmas!<!DOCTYPE html><html><head> <meta charset=utf-8" /> <
通過對JQuery基礎(chǔ)語法練習(xí),簡單了解了JQuery控制css屬性的用法,并學(xué)會了通過$("[id=div1]")的方法,用JQuery同時控制所有ID相同的div。也祝各位老師節(jié)日快樂,christmas!
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8" />
<title>無標(biāo)題文檔</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$("div").css("background","white")
$("button").click(function(){
$("[id=div1]").css("background","pink")
})
})
</script>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<br />
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<br />
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<br />
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<br />
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div id="div1" style="width:20px;height:20px;background:red;float:left;"></div>
<div style="width:20px;height:20px;background:#000;float:left;"></div>
<br />
<button>點擊</button>
</body>
</html>
Guru membetulkan:滅絕師太Masa pembetulan:2018-12-26 09:24:09
Rumusan guru:id的唯一性??!祝福收到了,下次不要犯這個低級錯誤啦!布局還是非常用心的