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]
}
});
<div class="option">
<div id="result">TextContent</div>
<button id="copy">Copy</button>
</div>
let result = document.getElementById("result");
let copy = document.getElementById("copy");
copy.addEventListener("click", function () {
copyToClipboard(result.innerText);
});
function copyToClipboard(text, onComplete) {
if (navigator.clipboard) {
navigator.clipboard
.writeText(text)
.then(() => {
if (typeof onComplete === "function") onComplete();
})
.catch((err) => {
console.error("Copy fail", err);
});
} else {
let area = document.createElement("textarea");
document.body.appendChild(area);
area.value = text;
area.select();
document.execCommand("copy");
document.body.removeChild(area);
if (typeof onComplete === "function") onComplete();
}
}
btn.forEach((key, index) => {
})
// Это коллекции - множественная форма
let buttons = document.querySelectorAll('.advertisement-tabs__item'); //Кнопки табой
let blocks = document.querySelectorAll('.advertisement-tabs__content') //Контент
// Что еще за key? Там кнопка
buttons.forEach((btn, index) => {
btn.addEventListener('click', function() {
console.dir(btn)
blocks.forEach(block => {
block.classList.toggle('active', btn === block)
})
})
})
if ($src) {
echo '<img src="'.$src.'">';
}
img[src=""] {
display: none;
}
img:not([src]) {
display: none;
}