abstrait:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="jqu
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="jquery-3.3.1.js"></script> <style type="text/css"> a{ color: red; width: 100px; height: 100px; display: block; background-color: #ccc; float: left; margin-left: 30px; line-height: 100px; text-align: center; text-decoration: none; border-radius: 50px; } </style> <script type="text/javascript"> function change(tag) { var leng=document.getElementsByTagName(tag).length; for(var i=0;i<leng;i++) { document.getElementsByTagName(tag)[i].style.backgroundColor = 'rgb(' + Math.floor(Math.random()*256)+','+ Math.floor(Math.random()*256)+',' +Math.floor(Math.random()*256)+')' } } $(document).ready(function(){ change('a'); $('a').mouseover(function(){ $bg = $(this).css('backgroundColor'); $(this).css("box-shadow","0px 0px 20px "+$bg); $(this).css("border-radius","20px"); }) $('a').mouseleave(function(){ $bg = $(this).css('backgroundColor'); $(this).css("box-shadow","none"); $(this).css("border-radius","50px"); }) }) </script> </head> <body> <a href="#">a</a> <a href="#">b</a> <a href="#">c</a> <a href="#">d</a> </body> </html>
經(jīng)過本案例學(xué)習(xí)發(fā)現(xiàn)dom的功能好強(qiáng)大,課外還需要多多練習(xí)讓dom里的功能運(yùn)用到得心應(yīng)手。
Professeur correcteur:韋小寶Temps de correction:2018-12-09 09:11:15
Résumé du professeur:寫的很不錯(cuò)!總得一個(gè)說是jquery很強(qiáng)大!哦不對(duì),應(yīng)該是js很強(qiáng)大!課后多多了解jquery,你會(huì)發(fā)現(xiàn)更牛X的東西哦!