-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (40 loc) · 1.64 KB
/
Copy pathscript.js
File metadata and controls
50 lines (40 loc) · 1.64 KB
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
44
45
46
47
48
49
50
const accountsData = [
{ username: 'user1', profilePic: 'https://via.placeholder.com/150', followers: 123 },
{ username: 'user2', profilePic: 'https://via.placeholder.com/150', followers: 123 },
{ username: 'user3', profilePic: 'https://via.placeholder.com/150', followers: 123 }
];
document.addEventListener('DOMContentLoaded', function() {
displayAccounts(accountsData);
});
function displayAccounts(accounts) {
const accountsGrid = document.getElementById('accounts-grid');
accounts.forEach(account => {
const card = createAccountCard(account);
accountsGrid.appendChild(card);
});
}
function createAccountCard(account) {
const card = document.createElement('div');
card.classList.add('account-card');
const profilePic = document.createElement('img');
profilePic.src = account.profilePic;
card.appendChild(profilePic);
const username = document.createElement('p');
username.textContent = `username: ${account.username}`;
card.appendChild(username);
const followers = document.createElement('p');
followers.textContent = `followers: ${account.followers}`;
card.appendChild(followers);
return card;
}
const addAccountButton = document.getElementById('add-account');
addAccountButton.addEventListener('click', function() {
const newAccount = {
username: 'newuser',
profilePic: 'https://via.placeholder.com/150',
followers: 500
};
const newCard = createAccountCard(newAccount);
const accountsGrid = document.getElementById('accounts-grid');
accountsGrid.appendChild(newCard);
});