File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
color changer mini app#1115 Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < link rel ="stylesheet " href ="styles.css ">
7+ < title > Color Changer Mini-App</ title >
8+ </ head >
9+ < body >
10+ < div id ="colorChangerApp ">
11+ < h1 > Color Changer Mini-App</ h1 >
12+ < label for ="elementSelector "> Select Element:</ label >
13+ < select id ="elementSelector ">
14+ < option value ="background "> Background</ option >
15+ < option value ="text "> Text</ option >
16+ </ select >
17+
18+ < label for ="colorPicker "> Choose Color:</ label >
19+ < input type ="color " id ="colorPicker " value ="#ff0000 ">
20+
21+ < button onclick ="changeColor() "> Apply Color</ button >
22+ </ div >
23+
24+ < script src ="script.js "> </ script >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ function changeColor ( ) {
2+ var selectedElement = document . getElementById ( 'elementSelector' ) . value ;
3+ var newColor = document . getElementById ( 'colorPicker' ) . value ;
4+
5+ var elementToChange = document . body ;
6+ if ( selectedElement === 'background' ) {
7+ elementToChange = document . body ;
8+ } else if ( selectedElement === 'text' ) {
9+ elementToChange = document . getElementById ( 'colorChangerApp' ) ;
10+ }
11+
12+ elementToChange . style . backgroundColor = newColor ;
13+ }
Original file line number Diff line number Diff line change 1+ body {
2+ font-family : 'Arial' , sans-serif;
3+ text-align : center;
4+ }
5+
6+ # colorChangerApp {
7+ margin : 50px ;
8+ }
9+
10+ button {
11+ padding : 10px ;
12+ margin-top : 10px ;
13+ cursor : pointer;
14+ }
15+
You can’t perform that action at this time.
0 commit comments