abstract:<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> <script> for(i=1;i<=100;i++){ for(j=1;j<=100;j++){
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> <script> for(i=1;i<=100;i++){ for(j=1;j<=100;j++){ document.write('<div onmouseenter="draw(this)" ></div>') } draw = function(x){ x.style.background="blue"; } document.write('<p></p>'); } </script> <style> *{margin:0;padding: 0;} div{width: 1px;height: 1px;background: #FFEFDB ;float: left;} p{ clear: both; } </style> </head> <body> </body> </html>
---------------------
思路:
1、用for循環(huán)嵌套for循環(huán),輸出100*100個div矩陣,設(shè)置寬高均為1像素;
2、用設(shè)置了clear屬性的p標(biāo)簽實現(xiàn)矩陣換行;
3、鼠標(biāo)進入div元素時,用mouseenter事件改變div背景
-------------------
效果圖(瀏覽器放大五倍)
總結(jié):
1、當(dāng)js進入100*100的循環(huán),瀏覽器反應(yīng)速度明顯變慢;
2、鼠標(biāo)移動過快時,mouseenter事件未能執(zhí)行
Correcting teacher:查無此人Correction time:2019-04-01 09:53:10
Teacher's summary:完成的不錯,就是這個圖形不怎么好看。繼續(xù)加油。