Initial commit
This commit is contained in:
21
js/script.js
Normal file
21
js/script.js
Normal file
@@ -0,0 +1,21 @@
|
||||
window.addEventListener('load', () => {
|
||||
const funkoTemplate = document.querySelector('#funkoTemplate');
|
||||
const funkoContainer = document.querySelector('#funkos');
|
||||
|
||||
funkos.forEach(funko => {
|
||||
const elem = funkoTemplate.content.cloneNode(true);
|
||||
const special = ['img', 'href'];
|
||||
|
||||
elem.querySelector('.funko__img').setAttribute('src', `img/${funko.img}.jpg`);
|
||||
elem.querySelector('.funko__readmore').setAttribute('href', `/${funko.href}.html`);
|
||||
|
||||
for (const [k, v] of Object.entries(funko)) {
|
||||
if (special.includes(k))
|
||||
continue;
|
||||
|
||||
elem.querySelector(`.funko__${k}`).innerHTML = v;
|
||||
}
|
||||
|
||||
funkoContainer.appendChild(elem);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user