-
Notifications
You must be signed in to change notification settings - Fork 2
/
appday15.js
35 lines (30 loc) · 948 Bytes
/
appday15.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
const li = document.createElement('li');
li.className = 'collection-item';
const textelement = document.createTextNode('One more element');
li.append(textelement);
document.querySelector('ul.collection').appendChild(li);
//Remove a element
const lis = document.querySelectorAll('li');
lis[5].remove();
const list = document.querySelector('ul');
list.removeChild(lis[0]);
//classes and attribute
const firstli = document.querySelector('li:first-child');
// firstli.className = 'test';
firstli.classList.add('test');
firstli.classList.remove('test');
console.log(firstli);
//
var link = document.querySelector('.link');
var val = link.getAttribute('href');
val = link.setAttribute('href', 'https://google.com');
val = link.removeAttribute('target');
console.log(val);
//
document.querySelector('.simplebutton').addEventListener('click', onclick);
//
function onclick(e) {
val = e.target;
val = e.target.className;
console.log(val);
}