Вёрстка
- 3 ответа
- 0 вопросов
1
Вклад в тег
let i,
arrayItem,
rows = arr.length,
tableBody = document.querySelector('.tbody');
for (i = 0; i < rows; i++) {
arrayItem = arr[i];
tableBody.innerHTML += `<tr><td>${arrayItem.id}</td><td>${arrayItem.name}</td><td>${arrayItem.last}</td><td>${arrayItem.com}</td></tr>`;
}
function createImageCardTemplate(image) {
let imageTemplate = document.createElement("div");
imageTemplate.classList.add(`${USER_GALLERY_CLASS}__item`, "js-show-image");
imageTemplate.setAttribute("data-target-image", image.id);
imageTemplate.innerHTML =
`<img class="${USER_GALLERY_CLASS}__image" src="${image.filePath}" alt="${image.fileName}">`;
return imageTemplate;
}
function renderGallery(images) {
let imagesCount = images.length,
$image,
imageData,
i;
$gallery.addEventListener("click", bindImageCardClick);
if (!imagesCount) {
$gallery.innerText = "No images found";
return;
}
$gallery.innerText = "";
for (i = 0; i < imagesCount; i++) {
imageData = images[i];
$image = createImageCardTemplate(imageData);
$gallery.appendChild($image);
}
}