[HTML5] 颜色选择器的操作[input type='color'....]

时间:2024-04-17 14:50:49

一、点击事件和获取颜色值

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body style=" background: rgb(238, 255, 255);">
    <input  type="color" id="onchange">
</body>
<script type="text/javascript">
    document.getElementById(\'onchange\').onchange = function(){
        document.getElementById(\'onchange\').click();
        document.body.style.background = this.value;
    };
</script>
</html>