File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
Expand file tree Collapse file tree 2 files changed +60
-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+ < title > Background Change Color</ title >
7+ </ head >
8+ < body >
9+ < div class ="bg-change ">
10+ < h1 > Change the background color.</ h1 >
11+ < Button class ="btn " id ="btn "> Change Color</ Button >
12+ </ div >
13+ </ body >
14+ < script >
15+ document . querySelector ( '#btn' ) . addEventListener ( 'click' , function ( e ) {
16+ const randomColor = '#' + Math . floor ( Math . random ( ) * 16777215 ) . toString ( 16 ) ;
17+ document . body . style . backgroundColor = randomColor ;
18+ } )
19+ </ script >
20+ </ html >
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+ < title > Circle Creation Button</ title >
7+ < style >
8+ body {
9+ transition : background-color 0.5s ease;
10+ text-align : center;
11+ }
12+ button {
13+ padding : 10px ;
14+ font-size : 16px ;
15+ cursor : pointer;
16+ }
17+ .circle {
18+ width : 100px ;
19+ height : 100px ;
20+ border-radius : 50% ;
21+ margin : 20px auto;
22+ }
23+ </ style >
24+ </ head >
25+ < body >
26+
27+ < button id ="btn "> Create Circle</ button >
28+ < div id ="circleContainer "> </ div >
29+
30+ < script >
31+ document . querySelector ( '#btn' ) . addEventListener ( 'click' , function ( e ) {
32+ const circle = document . createElement ( "div" ) ;
33+ circle . className = "circle" ;
34+ circle . style . backgroundColor = "blue" ;
35+ document . getElementById ( "circleContainer" ) . appendChild ( circle ) ;
36+ } )
37+ </ script >
38+
39+ </ body >
40+ </ html >
You can’t perform that action at this time.
0 commit comments