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 http-equiv ="X-UA-Compatible " content ="IE=edge ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < title > Chai aur code | DOM</ title >
8+ </ head >
9+ < body style ="background-color: #212121; color: #fff; ">
10+ < ul class ="language ">
11+ < li > Javascript</ li >
12+ </ ul >
13+ </ body >
14+ < script >
15+ function addLanguage ( langName ) {
16+ const li = document . createElement ( 'li' ) ;
17+ li . innerHTML = `${ langName } `
18+ document . querySelector ( '.language' ) . appendChild ( li )
19+ }
20+ addLanguage ( "python" )
21+ addLanguage ( "typescript" )
22+
23+ function addOptiLanguage ( langName ) {
24+ const li = document . createElement ( 'li' ) ;
25+ li . appendChild ( document . createTextNode ( langName ) )
26+ document . querySelector ( '.language' ) . appendChild ( li )
27+ }
28+ addOptiLanguage ( 'golang' )
29+
30+ //Edit
31+ const secondLang = document . querySelector ( "li:nth-child(2)" )
32+ console . log ( secondLang ) ;
33+ //secondLang.innerHTML = "Mojo"
34+ const newli = document . createElement ( 'li' )
35+ newli . textContent = "Mojo"
36+ secondLang . replaceWith ( newli )
37+
38+ //edit
39+ const firstLang = document . querySelector ( "li:first-child" )
40+ firstLang . outerHTML = '<li>TypeScript</li>'
41+
42+ //remove
43+ const lastLang = document . querySelector ( 'li:last-child' )
44+ lastLang . remove ( )
45+
46+
47+ </ script >
48+ </ html >
You can’t perform that action at this time.
0 commit comments