This article example shares the specific code of JavaScript to implement the color viewer for your reference. The specific content is as follows Achieve results
Implementation Code<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Color Viewer</title> <style> #color { width: 150px; height: 150px; background-color: #fff; border: 1px solid #000; } </style> </head> <body> <div id="color"></div> <input id="inp" type="text" placeholder="Please enter the color code..." /> <button id="trans">View Color</button> <button id="rst">Restore</button> </body> <script> let trans = document.getElementById('trans'); let color = document.getElementById('color'); let inp = document.getElementById('inp'); let rst = document.getElementById('rst'); trans.addEventListener('click', () => { color.style.backgroundColor = inp.value; }); rst.addEventListener('click', () => { color.style.backgroundColor = '#fff'; inp.value = ''; }); </script> </html> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed installation and use of SSH in Ubuntu environment
>>: Summary of common functions of PostgreSQL regular expressions
I recently reviewed some CSS-related knowledge po...
I just tried it on IE6, and it does show the toolb...
Create Table create table table name create table...
Table of contents Preface 1. EndPoint 2. Connecti...
This article shares the specific code of Vue to i...
Scenario 1: Html: <div class="outer"...
Software and hardware environment centos7.6.1810 ...
DIV background is semi-transparent, but the words ...
All previous projects were deployed in the Window...
Set Anchor Point <a name="top"><...
1. Fixed width + adaptive Expected effect: fixed ...
1. Introduction A few days ago, a development col...
First, the HTML code to embed the video in the pag...
Table of contents 1. Introduction 2. Solution Imp...
Canvas has always been an indispensable tag eleme...