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 > Chai aur code | DOM</ title >
7+ </ head >
8+ < body style ="background-color: #212121; color: aliceblue; ">
9+ < ul class = "language ">
10+ < li > Javascript</ li >
11+ </ ul >
12+ </ body >
13+ < script >
14+ function addLanguage ( langNAme ) {
15+ const li = document . createElement ( 'li' )
16+ li . innerHTML = `${ langNAme } `
17+ document . querySelector ( '.language' ) . appendChild ( li )
18+ }
19+ addLanguage ( "python" ) ;
20+ addLanguage ( "typeScript" ) ;
21+
22+ function addOptiLanguage ( langNAme ) {
23+ const li = document . createElement ( 'li' ) ;
24+ li . appendChild ( document . createTextNode ( langNAme ) ) ;
25+ document . querySelector ( '.language' ) . appendChild ( li ) ;
26+ }
27+ addOptiLanguage ( 'golang' ) ;
28+
29+ //EDIT
30+ const secondLang = document . querySelector ( "li:nth-child(2)" )
31+ console . log ( secondLang ) ;
32+ //secondLang.innerHTML = "MOJo"
33+ const newli = document . createElement ( 'li' )
34+ newli . textContent = "Mojo"
35+ secondLang . replaceWith ( newli ) ;
36+
37+ //edit
38+ const firstLang = document . querySelector ( "li:first-child" )
39+ firstLang . outerHtml = '<li>TypeScript</li>'
40+
41+ //remove
42+ const lastLang = document . querySelector ( 'li:last-child' )
43+ lastLang . remove ( )
44+ </ script >
45+ </ html >
You can’t perform that action at this time.
0 commit comments