const panel = document.querySelector("#panel");
const button = document.querySelector("#button");
const buttonObserverCallback = (entries) => {
entries.forEach(entry => {
const isButtonAbove = entry.boundingClientRect.bottom < 0;
panel.classList.toggle("d-hide", isButtonAbove);
});
};
const intersectionObserver = new IntersectionObserver(buttonObserverCallback, { threshold: 0 });
intersectionObserver.observe(button);
map()
и поместить обе карточки в один <Grid>
элемент. var api = new DOMParser().parseFromString(this.responseText, "text/html"); api = CommentsSite.responseText;
querySelector()
, remove()
и т.д.async function getComments() {
const response = await fetch(`/comments.lm?com="${location.pathname}`);
const commentsRawString = await response.text();
const commentsParsedPage = new DOMParser().parseFromString(commentsRawString, "text/html");
const comments = Array.from(commentsParsedPage.querySelectorAll(/*селектор для поиска комментариев*/), comment => comment.textContent);
return comments;
}
const target = document.querySelector(''); //наблюдаемый элемент
const observer = new MutationObserver(mutationsList => {
mutationsList.forEach(({ target }) => {
if (!target.classList.contains('yith-wcwl-items-count')) return;
const isEmpty = target.textContent.trim() === '0';
target.classList.toggle('hidden', isEmpty);
})
});
observer.observe(target, { childList: true, characterData: true });
/(?<="availability" href=").+?(?=">)/
cardRecommended.forEach((card) => {
card.addEventListener('click', (e) => {
if (popupRecommended.classList.contains('-open') || e.target.classList.contains('favorite-btn')) return;
popupRecommended.classList.add('-open');
document.body.classList.add('-lock');
})
})
.replace
с регулярным выражением и флагом i
.replace(/hello/gi, `<span>$&</span>`)
if
для вычисления mapp1convert уже не проводится.const accordTitles = document.querySelectorAll('.elem-top');
accordTitles.forEach(title => {
title.addEventListener('click', textdown)
})
function textdown({currentTarget}) {
currentTarget.nextElementSibling.classList.toggle('active_text');
currentTarget.querySelector('.faq__arrow').classList.toggle('arrow_rotate');
};
querySelector
const tree = document.querySelector('#tree');
tree.addEventListener('click', function({target}) {
if (target.tagName !== 'LI' || !target.hasChildNodes()) return;
target.querySelector('ul').classList.toggle('no')
})