返回2019-8-......登陆

2019-8-21 jquery随机色与随机值

辰晨2019-08-21 10:18:121575

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>随机值与随机色</title>

<script src="https://code.jquery.com/jquery-3.4.1.js"></script>

<style>

a{

display:block;

width:100px;

height:100px;

color:#fff;

float: left;

margin:30px;

border-radius: 50%;

text-decoration: none;

text-align: center;

line-height: 100px;

font-size: 20px;

}

button{

float:left;

}

</style>

</head>

<body>

<script>

$(document).ready(function(){

function ref(){

$('a').each(function(){

$(this).css('backgroundColor','rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')');

})

$('a').each(function(){

$(this).text(Math.floor(Math.random()*99));

})

}

ref();

$('button').click(function(){

ref();

})

})

</script>

<button>刷新</button>

<a href="">1</a>

<a href=""></a>

<a href=""></a>

<a href=""></a>

<a href=""></a>

<a href=""></a>

</body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送