<a data-problem="value1">
<a data-problem="value2">
<a data-problem="value1|value2">
$('.problem').change(function() {
const problems = $(':checked', this)
.get()
.map(({ dataset: { type, problem } }) => ({ type, problem }));
$(this)
.closest('.remont')
.find('.price__item')
.hide()
.filter((i, { dataset: d }) =>
problems.some(p => d.type === p.type && d.problem.includes(p.problem))
)
.show();
}).change();
deep:true
obj[key] = val
делайте obj = { ...obj, [key]: val }
. const xxx = arr =>
arr.reduce((acc, n) => (
Object
.entries(n)
.forEach(([ k, v ]) => (acc[k] ||= []).push(v)),
acc
), {});
.product { display: flex;
flex-direction: column;
для .product
. Элементам внутри .product
, которые должны находиться на одной строке, добавьте общие обёртки, которым также будет задан display: flex;
. $('.problem').change(({ target: t }) => {
const attrsSelector = [ 'type', 'problem' ]
.map(n => `[data-${n}="${t.dataset[n]}"]`)
.join('');
$(`.price-problem ${attrsSelector}`).toggle(t.checked);
}).find('input').change();
$arr3 = array_map(fn($n, $m) => array_merge($n, [ 'quantity' => $m ]), $arr1, $arr2);
$('.item img').wrap(function() {
return `<a href="${this.getAttribute('src')}"></a>`;
});
$('.item').html((i, html) => `<a href="${html.match(/(?<=src=")[^"]*/)}">${html}</a>`);
preg_match('/\/season\/(\d+)\//', $string, $match);
$season = $match[1];
$input.change();
на $input.get(0).dispatchEvent(new Event('input'));
.$input.on('input', ...
), тогда вместо $input.change();
должно быть $input.trigger('input');
. const $items = $('селектор элементов');
const className = 'имя класса';
let index = -1;
$('селектор кнопки').click(function() {
$items.eq(index).removeClass(className);
index = (index + 1) % $items.length;
$items.eq(index).addClass(className);
});
const markersData = [
{ position: { lat: ..., lng: ... }, content: '...' },
{ position: { lat: ..., lng: ... }, content: '...' },
...
];
const infoWindow = new google.maps.InfoWindow();
const markers = markersData.map(({ position, content }) => {
const marker = new google.maps.Marker({ position, map });
marker.addListener('click', () => {
infoWindow.setContent(content);
infoWindow.open(map, marker);
});
return marker;
});
null
):const setActiveIcon = marker => markers.forEach(n => n.setIcon(n === marker ? iconActive : icon));
function createTree(arr) {
const tree = Object.fromEntries(arr.map(({ parts, ...n }) => [ n.id, n ]));
arr.forEach(n => tree[n.id].children = n.parts?.map(m => tree[m]) ?? []);
return Object.values(tree).filter(n => arr.every(m => !m.parts?.includes(n.id)));
}
<div class="wrapper">
.$('.request__nav').on('click', '.request__nav__item', function() {
const $this = $(this);
$this
.addClass('active')
.siblings()
.removeClass('active')
.closest('.wrapper')
.find('.request__field')
.hide()
.eq($this.index())
.fadeIn();
}).each(function() {
$('.request__nav__item', this).first().click();
});
$('a').click(function() {
const $tabs = $('.splCont');
const $tab = $tabs.eq($(this).index()).toggle('normal');
$tabs.not($tab).hide('normal');
return false;
});
row = [ 2, 3, 7, 9 ]
num_rows = 5
matrix = [ [ f'Ряд {i + 1}, число {item}' for item in row ] for i in range(num_rows) ]
const toSeconds = str => str
.split(':')
.reverse()
.reduce((acc, n, i) => acc + n * (60 ** i), 0);