document.querySelector('.post-list').innerHTML += `
<div class="card" style="...">
<div class="card-body">
<h5 class="card-title">${post.title}</h5>
<p class="card-text">${post.body}</p>
<a href="#" class="card-link">Подробнее</a>
</div>
</div>`
posts.array.forEach
const menu = document.getElementById('menu');
const scroll = 128;
function toggleFixedMenu() {
menu.classList.toggle('fixed', window.pageYOffset > scroll);
menu.classList.toggle('default', window.pageYOffset <= scroll);
}
window.addEventListener('scroll', toggleFixedMenu);
toggleFixedMenu();
body.onclick = function(){
body.style.backgroundColor = 'black'
setTimeout(() => {
body.style.backgroundColor = ''; // Пустое значение установит то, что прописано изначально в css
}, 2000);
}
button.onclick = function(){
const saved = button.value; // Запомним, что было
button.value = 'НАЖИМАЙ!'
setTimeout(() => {
button.value = saved;
}, 2000);
}
const quantityElement = document.querySelector('#quantityitog');
const plusButtonElement = document.querySelector('#plustab');
const minusButtonElement = document.querySelector('#minustab');
const totalElement = document.querySelector('#totalprice');
const priceElement = document.querySelector('#countprice');
let total = +totalElement.innerText;
let qty = +quantityElement.innerText;
let price = +priceElement.innerText;
function updateView(){
totalElement.innerHTML = total;
}
function increment(){
qty++;
total = Math.trunc((qty * price) * 100) / 100;
updateView();
}
function decrement(){
qty--;
total = Math.trunc((total - price) * 100) / 100;
if (total < 0) total = 0;
updateView();
}
plusButtonElement.addEventListener('click', increment)
minusButtonElement.addEventListener('click', decrement)
let teams = {
2522: {id: 1, team: 'Arsenal', palyed: 10, win: 5, loss: 3, draw: 2, goalsFor: 12, goalsAgainst: 13},
2520: {id: 2, team: 'Aston Villa', palyed: 10, win: 3, loss: 6, draw: 1, goalsFor: 14, goalsAgainst: 19},
}
const result = response.data.map(item => {
return {
...item,
...teams[item.team_id]
}
});