function wrap(el, wrapper) {
el.parentNode.insertBefore(wrapper, el);
wrapper.appendChild(el);
}
wrap(document.querySelector('a.wrap_me'), document.createElement('div'));
function wrap(parent, className = 'wrapper') {
const wrapper = document.createElement('div');
wrapper.classList = className;
parent.childNodes.forEach(ch => wrapper.appendChild(ch));
parent.appendChild(wrapper);
}
document.querySelectorAll('td')
.forEach(td => wrap(td, 'text'));
// Ajax обновление корзины
const ajaxUpdateCartContainer = document.querySelector('div.woocommerce');
if (ajaxUpdateCartContainer){
ajaxUpdateCartContainer.addEventListener('change', ({ target }) => {
target.closest('input.qty');
document.querySelector('[name="update_cart"]').click();
});
}
.pic {
display: inline-block;
}
.pic img {
opacity: 1;
transition: opacity 1s linear;
}
.pic img.invisible {
opacity: 0;
}
button {
padding: 1em;
}
button.active {
background: tomato;
}
document.body.addEventListener('click', e => {
if (!e.target.matches('button')) return
const img = document.querySelector('.pic img')
img.classList.add('invisible')
img.ontransitionend = () => {
img.onload = () => img.classList.remove('invisible')
img.src = e.target.dataset.src
document.querySelectorAll('button').forEach(btn => btn.classList.remove('active'))
e.target.classList.add('active')
}
})
navigator.mediaDevices.getUserMedia({video: true})
$('.cart-arrow, main')
какие по Вашему выбираются элементы в этом селекторе?button.addEventListener('click', (event) => {
event.preventDefault();
fetch('https://test.ru/?id=5&rating=5');
});
pm = new ymaps.GeoObject({
geometry: { type: "Point", coordinates: item.p },
properties: { id: item.id, c: item.c }
}, {
iconLayout: myIconContentLayout,
iconShape: {
type: 'Rectangle',
coordinates: [
[-50, -60], [50, 30]
]
},
openBalloonOnClick: false
});