摘要:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>jQuery的動畫效果--獲取隨機顏色</title> <script type="text/javascript" src="j
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery的動畫效果--獲取隨機顏色</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
a{float:left;
display:block;
margin:50px;
width:100px;
height:100px;
line-height: 100px;
text-align:center;
color:#fff;
border-radius:50px;
text-decoration: none;
}
.but1{width:200px;height:60px;margin-top:68px;}
</style>
<script type="text/javascript">
function sjcolor(tag){
var len=document.getElementsByTagName(tag).length
for(var i=0;i<len;i++){
document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'
}
}
function sjshu(tag){
var len=document.getElementsByTagName(tag).length
for(var i=0;i<len;i++){
document.getElementsByTagName(tag)[i].innerText=Math.floor(Math.random()*100+1)
}
}
$(document).ready(function(){
// sjcolor('a')
$('.but1').click(function(){
sjcolor('a')
sjshu('a')
})
$('a').mouseover(function(){
$bg=$(this).css('backgroundColor')
$(this).css('box-shadow','0px 0px 20px '+$bg)
$(this).css('border-radius','20px')
})
$('a').mouseleave(function(){
$(this).css('box-shadow',"none")
$(this).css('border-radius','50px')
})
})
</script>
</head>
<body>
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
<button class="but1">點擊改變</button>
</body>
</html>
老師 如果我想把那個button放到四個圈圈的下面 css該怎么寫。。。一下子想不起來了 還有jquery和js用的時候很容易搞混,可能是因為前后學(xué)習(xí)的關(guān)系,有沒有什么好的辦法呢?
批改老師:韋小寶批改時間:2019-02-25 17:37:59
老師總結(jié):button放到四個圈圈的下面 這個css你能不會寫??? 之前css是怎么學(xué)的 你可以把4個a標(biāo)簽和一個按鈕放在一個div中 再把樣式改一下就可以 樣式修改的方法有很多種 這個要靠自己去練習(xí)的
jQuery的所有語法都比js的要簡潔 要記得多去練習(xí)多去練習(xí)多去練習(xí) 不要感覺看視頻懂了就不用練習(xí)了