const parentBlock = document.querySelector('.parent-block');
parentBlock.addEventListener('click', ({target}) => {
if (!target.classList.contains('btn')) return;
const allPageSelects = document.querySelectorAll('select');
allPageSelects.forEach(select => {
console.log(select.options[select.selectedIndex].textContent);
});
})
wife: mother
, т.к. объект mother
ещё не существует. А функция работает с уже созданными объектами:const father = {
name: "John",
}
const mother = {
name: "Ann",
}
father.wife = mother;
mother.husband = father;
const family = {father, mother}
function readMore({ target }) {
const item = target.closest('.reference-body-left-item');
const ellipsis = item.querySelector('.reference-body-left-dots');
const hiddenText = item.querySelector('.reference-body-left-more');
const isHiding = target.textContent === 'Скрыть текст';
target.textContent = isHiding ? 'Читать далее' : 'Скрыть текст';
ellipsis.style.display = isHiding ? 'inline' : 'none';
hiddenText.style.display = isHiding ? 'none' : 'inline';
}
const salaryFilter = document.querySelector('.third__filter-item');
const salaryFilterFrom = salaryFilter.querySelector('.third__filter-from');
const salaryFilterTo = salaryFilter.querySelector('.third__filter-to');
const cvBlocks = document.querySelectorAll('.watch__anceta');
salaryFilter.addEventListener('input', filterBySalary);
function filterBySalary() {
cvBlocks.forEach(cvBlock => {
const salary = +cvBlock.querySelector('.watch__price').textContent.match(/\d+/);
const isInRange = salary >= +salaryFilterFrom.value && salary <= +salaryFilterTo.value;
cvBlock.classList.toggle('hide', !isInRange);
})
}
document.querySelector('.third__filter-btn').addEventListener('click', () => {
const filteringItems = document.querySelectorAll('.filter-man, .filter-woman');
const checkedValue = document.querySelector('.third__filter-radio-input:checked').value;
filteringItems.forEach(item => {
const isPassive = checkedValue !== 'all' && !item.classList.contains(`filter-${checkedValue}`);
item.classList.toggle('passive', isPassive);
})
})
document.addEventListener('click', ({target}) => {
if (target.closest('header .ms ul li a') || !target.closest('.ms')) {
document.getElementById('burger').checked = false;
};
});
function renderItem(cardData) {
const newCard = cardTemplate.cloneNode(true);
const cardTitle = newCard.querySelector('.card__title');
const cardImage = newCard.querySelector('.card__image');
cardImage.src = cardData.link;
cardTitle.textContent = cardData.name;
container.append(newCard);
}
renderItem(); //← поэтому семь
render();
const modalButtons = document.querySelectorAll('.button a');
modalButtons.forEach(button => {
button.addEventListener('click', setModalTitle);
})
function setModalTitle({ target }) {
const titleText = target.closest('.item').querySelector('h2').textContent;
const modalTitle = document.querySelector('.modal h3');
target.title = titleText;
modalTitle.textContent = titleText;
}
let choice = new Set([1,2,3,4]);
let choiceArr = [...choice];
let currentMonth = 1;
let object = {
[choiceArr[0]] : currentMonth,
[choiceArr.at(-1)] : currentMonth
}
padding: 10px 450px 15px 27px;В padding задаются отступы, а не ширина элемента.
elSelectCustom
- это коллекция элементов. У неё нет свойсв .children
. Нужно обращаться просто как elSelectCustom[0]
.elSelectCustom.classList.toggle("isActive")
Нельзя задать класс коллекции. const result = document.querySelector('.result');
const inputContainer = document.querySelector('.input-container');
inputContainer.addEventListener('input', () => {
result.textContent = Array.from(
inputContainer.querySelectorAll('.input_js'),
input => Number(input.value)
).reduce((a, b) => a + b);
});