选色器

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		div{width: 150px;height: 150px;border: 1px solid gray;}
	</style>
</head>
<body>
	<input type="color" id="ipt">
	<div id="box"></div>
	<script type="text/javascript">
		var ipt=document.getElementById('ipt');
		var o=document.getElementById("box");
		o.style.background=ipt.value;
		ipt.onchange=function(){
             o.style.background=ipt.value;
		};           
	</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_44606660/article/details/87773955