-
Notifications
You must be signed in to change notification settings - Fork 0
/
practise2.js
43 lines (29 loc) · 927 Bytes
/
practise2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
let div = document.querySelector("div");
console.log(div)
let id1=div.getAttribute("id");
console.log(id1)
let doc = document.querySelector("p")
// let doc1=doc.getAttribute("class");
// console.log(doc1)
// let doc2=doc.setAttribute("class","paragraph1")
// console.log(doc.setAttribute("class","paragraph1"))
let div1 = document.querySelector("div")// sconsole.dir(div1)
//creat and then add
let el = document.createElement("h1")
el.innerText="ending (append)"
let el2 = document.createElement("h1")
el2.innerText="starting prepend"
let div3=document.querySelector("div")
div3.append(el);//ending of the div
div3.prepend(el2)
div3.before(el2)
div3.after(el)
//create and then add
let elr = document.createElement("button")
elr.innerText="click me"
divr=document.querySelector("div")
divr.append(elr)
let para=document.querySelector("p")
para.remove()
let heading1=document.querySelector("h1")
heading1.remove()