php 点击变色,随即色点击变色变数字

摘要:

Document

* {

margin: 0;

padding: 0;

}

body {

font-family: "微软雅黑";

font-size: 18px;

text-align: center;

line-height: 40px;

}

ul,

ol,

li {

list-style: none;

}

div {

width: 100px;

height: 100px;

border-radius: 50px;

text-align: center;

line-height: 100px;

float: left;

cursor: pointer;

margin: 20px;

}

(function() {

var aDiv = document.getElementsByClassName("circle");

changeColor();

function changeColor() {

for (var i = 0; i 

var r = parseInt(Math.random() * 255),

g = parseInt(Math.random() * 255),

b = parseInt(Math.random() * 255);

aDiv[i].style.background = `rgb(${r},${g},${b})`;

aDiv[i].innerHTML = r + g - b;

}

}

$(".circle").click(function() {

changeColor();

});

$(".circle").mouseover(function() {

$bg = $(this).css("backgroundColor");

$(this).css("box-shadow", "0px 0px 20px " + $bg);

$(this).css("border-radius", "20px ");

});

$(".circle").mouseleave(function() {

$(this).css("box-shadow", "none");

$(this).css("border-radius", "50px ");

});

})();

b0fd893c1405efbd3a2e7add7c5e56a7.png

批改老师:灭绝师太批改时间:2019-03-22 15:47:28

老师总结:最好做个点击按钮,也可以试着用不同于上课案例的方法来完成哦!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值