File tree Expand file tree Collapse file tree
task07-show-hide-paragraph Expand file tree Collapse file tree 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 > Show / Hide Paragraph</ title >
7+ < link rel ="stylesheet " href ="style.css ">
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < h1 > Hide / Show Paragraph</ h1 >
12+ < div class ="input-sec ">
13+ < p id ="para "> this is a paragraph</ p >
14+ < button id ="clickBtn "> Hide</ button >
15+ </ div >
16+ </ div >
17+
18+ < script src ="script.js "> </ script >
19+ </ body >
20+ </ html >
Original file line number Diff line number Diff line change 1+ const paragraph = document . getElementById ( "para" ) ;
2+ const button = document . getElementById ( "clickBtn" ) ;
3+
4+ button . addEventListener ( "click" , ( ) => {
5+ if ( paragraph . style . display === "none" ) {
6+ paragraph . style . display = "block" ;
7+ button . textContent = "Hide" ;
8+ }
9+ else {
10+ paragraph . style . display = "none" ;
11+ button . textContent = "Show" ;
12+ }
13+ } ) ;
Original file line number Diff line number Diff line change 1+ body {
2+ font-family : cursive;
3+ text-align : center;
4+ padding : 100px ;
5+ background-color : cornflowerblue;
6+ }
7+
8+ .container {
9+ width : 30% ;
10+ background-color : white;
11+ margin : auto;
12+ padding : 30px 20px 50px 20px ;
13+ border : none;
14+ border-radius : 50px ;
15+ }
16+
17+ .input-sec {
18+ display : flex;
19+ align-items : center;
20+ justify-content : space-around;
21+ gap : 10px ;
22+ }
23+
24+ p {
25+ font-size : 20px ;
26+ }
27+
28+ button {
29+ padding : 9px 20px ;
30+ cursor : pointer;
31+ font-size : 15px ;
32+ font-weight : 600 ;
33+ border : 2px solid chartreuse;
34+ border-radius : 8px ;
35+ background-color : chartreuse;
36+ }
You can’t perform that action at this time.
0 commit comments