-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom.js
More file actions
24 lines (23 loc) Β· 840 Bytes
/
dom.js
File metadata and controls
24 lines (23 loc) Β· 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Hazrat Ali
// University Of Scholars
document.getElementById('add-border').addEventListener('click', function () {
const container = document.getElementById('friend-container');
container.style.border = '3px solid yellow';
});
// dom js
function addBackgroundColor() {
const friends = document.getElementsByClassName('friend');
for (const friend of friends) {
friend.style.backgroundColor = 'lightblue';
}
}
document.getElementById('add-friend').addEventListener('click', function () {
const container = document.getElementById('friend-container');
const friendDiv = document.createElement('div');
friendDiv.classList.add('friend');
friendDiv.innerHTML = `
<h3 class="friend-name">New Friend</h3>
<p>Quam, sapiente.</p>
`;
container.appendChild(friendDiv);
})