File tree Expand file tree Collapse file tree
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 > Dom Part 2</ title >
7+ < link rel ="stylesheet " href ="style.css "/>
8+ </ head >
9+ < body >
10+ < h1 > Hello </ h1 >
11+ < div id ="box " name ="Jsdiv "> This is div
12+
13+ < ul >
14+ List
15+ < li > item 1</ li >
16+ < li > item 2</ li >
17+ < li > item 3</ li >
18+ </ ul >
19+ </ div >
20+ < p class ="para "> This is First Paragraph</ p >
21+
22+ < script src ="scripts.js "> </ script >
23+ </ body >
24+
25+ </ 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 > Practice Q1</ title >
7+ < link rel ="stylesheet " href ="style.css "/>
8+ </ head >
9+ < body >
10+
11+
12+ < script src ="practice.js "> </ script >
13+ </ body >
14+ </ html >
Original file line number Diff line number Diff line change 1+ let newbtn = document . createElement ( "button" ) ;
2+ newbtn . innerText = "click Me..!" ;
3+ newbtn . style . color = "white" ;
4+ newbtn . style . backgroundColor = "red" ;
5+ document . querySelector ( "body" ) . prepend ( newbtn ) ;
6+
7+
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 > Practice Q2</ title >
7+ < link rel ="stylesheet " href ="style.css "/>
8+ </ head >
9+ < body >
10+
11+ < p class ="content "> I am a Paragraph.</ p >
12+ < script src ="practice2.js "> </ script >
13+ </ body >
14+ </ html >
Original file line number Diff line number Diff line change 1+ let para = document . querySelector ( "p" ) ;
2+ console . log ( para ) ;
3+ console . log ( para . classList ) ;
4+
5+ let newpara = para . classList . add ( "newclass" ) ;
6+ console . log ( newpara ) ;
Original file line number Diff line number Diff line change 1+ let div = document . querySelector ( "div" ) ;
2+ console . log ( div ) ;
3+ let id = div . getAttribute ( "id" ) ;
4+ console . log ( id ) ;
5+
6+ let name = div . getAttribute ( "name" ) ;
7+ console . log ( name ) ;
8+
9+
10+ let para = document . querySelector ( "p" ) ;
11+ //console.log(para.setAttribute("class","new para"));
12+ para . remove ( ) ;
13+
14+
15+
16+ let btn = document . createElement ( "button" ) ;
17+ btn . innerText = "click me" ;
18+ console . log ( btn ) ;
19+
20+ let div1 = document . querySelector ( "div" ) ;
21+ div . append ( btn ) ;
22+ div . prepend ( btn ) ;
23+ div . before ( btn ) ;
24+ div . after ( btn ) ;
25+
Original file line number Diff line number Diff line change 1+ .content {
2+ color : red;
3+
4+ }
5+
6+ .newclass {
7+ background-color : green;
8+
9+ }
You can’t perform that action at this time.
0 commit comments