const parent = document.querySelector('#questions');
const selector = '#point';const children = [...parent.children];
const index = -~children.findIndex(n => n.matches(selector));
index && parent.replaceChildren(...children.slice(0, index));
// или
for (
const el = parent.querySelector(selector);
el?.nextElementSibling;
el.nextElementSibling.replaceWith()
) ;
// или
parent.querySelectorAll(`${selector} ~ *`).forEach(n => n.remove());
document.querySelector('.shopWrapper').addEventListener('mouseover', function() {
const color = `#${Math.random().toString(16).slice(2, 8).padEnd(6, 0)}`;
this.style.setProperty('--random-color', color);
});
print('\n'.join(f'{k}: {v}' for k, v in collections.Counter(selled).items()))
arr.map(n => {
const ids = Object
.values(n.childrenHash.reduce((acc, m) => ((acc[m.hash] ??= []).push(m.id), acc), {}))
.filter(m => m.length > 1);
return {
...n,
childrenHash: ids.length ? ids : null,
};
})
const table = document.querySelector('здесь селектор вашей таблицы');
const className = 'active';table.querySelectorAll('tbody td').forEach(td => {
td.classList.toggle(className, !td.textContent.trim());
});for (const { rows } of table.tBodies) {
for (const { cells } of rows) {
for (const td of cells) {
if (/^\s*$/.test(td.innerText)) {
td.classList.add(className);
}
}
}
}
props: { user: String }, emits: ["update:someUser"]
- emits: ["update:someUser"]
+ emits: ["update:user"]- @input="$emit('update:someUser', $event.target.value)"
+ @input="$emit('update:user', $event.target.value)"
const sumIntervals = intervals => intervals
.slice()
.sort((a, b) => a[0] - b[0])
.reduce((acc, n) => {
const top = acc.at(-1);
if (!top || top[1] < n[0]) {
acc.push([...n]);
} else if (top[1] < n[1]) {
top[1] = n[1];
}
return acc;
}, [])
.reduce((acc, n) => acc - n[0] + n[1], 0);
const where = '.container';
const what = '.wrapper-item h3';$(where).prepend(function() {
return $(what, this);
});document.querySelectorAll(where).forEach(n => {
const el = n.querySelector(what);
n.prepend(el);
// или
n.insertBefore(el, n.firstChild);
// или
n.insertAdjacentElement('afterbegin', el);
// или
n.firstChild.replaceWith(el, n.firstChild);
// или
n.replaceChildren(el, ...n.childNodes);
});
const index = 1;
const className = 'active';navigation.children[index]?.classList.add(className);navigation.innerHTML = objectNavigation
.map((n, i) => `
<div class="${i === index ? className : ''}">
<img src="${n.image}">
</div>`)
.join('');navigation.append(...objectNavigation.map((n, i) => {
const div = document.createElement('div');
const img = document.createElement('img');
img.src = n.image;
div.append(img);
div.classList.toggle(className, i === index);
return div;
}));for (const [ i, n ] of objectNavigation.entries()) {
navigation.appendChild(document.createElement('div'));
navigation.lastChild.appendChild(new Image);
navigation.lastChild.lastChild.src = n.image;
navigation.lastChild.className = i === index ? className : '';
}
data: () => ({
items: [
{ text: '69', tooltip: 'hello, world!!' },
{ text: '187', tooltip: 'fuck the world' },
{ text: '666', tooltip: 'fuck everything' },
],
}),<div
v-for="n in items"
v-text="n.text"
:data-tooltip="n.tooltip"
class="item"
></div>.item {
display: inline-flex;
justify-content: center;
align-items: center;
color: white;
background: red;
width: 150px;
height: 50px;
margin: 10px;
position: relative;
}
.item:hover::before {
content: attr(data-tooltip);
display: inline-block;
background: blue;
color: white;
position: absolute;
}
computed: {
filteredWorks() {
const category = this.tabs.find(n => n.id === this.activeTabId)?.category;
return category равна той, что у 'Все работы'
? this.works
: this.works.filter(n => n.category === category);
},<div class="articles__items articles__items--works">
<img v-for="n in filteredWorks" :key="n.id" :src="n.image">
</div>tabs: [ { id: '1', name: 'Все работы', category: 'doors' }, { id: '2', name: 'Окна', category: 'windows' }, { id: '3', name: 'Двери', category: 'doors' },