create: function() {
на create: function(e, ui) {
. document.querySelector('.nav__list').addEventListener('click', function(e) {
const sub = e.target.nextElementSibling;
if (sub && sub.classList.contains('nav__sublist')) {
sub.classList.toggle('nav--show');
}
});
<input type="date" v-model="years.start">
<input type="date" v-model="years.end">
<div v-for="n in months">
<h3>{{ n.year }}, {{ n.name }}</h3>
<div>{{ n.days }}</div>
</div>
data: () => ({
years: {
start: null,
end: null,
},
}),
computed: {
months() {
const start = moment(this.years.start).startOf('month');
const end = moment(this.years.end).endOf('month');
const months = [];
for (; start < end; start.add(1, 'day')) {
const [ year, name, day ] = start.format('YYYY.MMMM.D').split('.');
if (day === '1') {
months.push({
year,
name,
days: [],
});
}
months[months.length - 1].days.push(+day);
}
return months;
},
},
отследить появление содержимого блока
array_splice($arr, 2, 0, 'Груши');
А если мы не знаем порядковый номер нового элемента, но знаем после какого элемента будет стоять новый, то как быть?
array_splice($arr, array_search('Виноград', $arr) + 1, 0, 'Груши');
for (const k in obj) {
obj[k] = Object.values(obj[k]);
}
const newObj = Object
.keys(obj)
.reduce((acc, k) => (acc[k] = Object.values(obj[k]), acc), {});
// или
const newObj = Object.fromEntries(Object
.entries(obj)
.map(n => [ n[0], Object.values(n[1]) ])
);
const ul = document.querySelector('#ul');
const button = document.querySelector('#but');
ul.addEventListener('click', function(e) {
if (e.target.tagName === 'LI') {
e.target.textContent += '!';
}
});
button.addEventListener('click', function() {
const li = document.createElement('li');
li.textContent = `пункт ${ul.children.length + 1}`;
ul.appendChild(li);
});
ul.addEventListener('click', ({ target: t }) => t.matches('li') && t.append('!'));
button.addEventListener('click', () => {
ul.insertAdjacentHTML('beforeend', `<li>пункт ${-~ul.children.length}</li>`);
});
не срабатывают case, всегда default
.gray {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
}
map.panes.get('ground').getElement().classList.add('gray');
async function processData(data, process, chunkSize, delay) {
let i = -1;
for (const n of data) {
if (++i === chunkSize) {
i = 0;
await new Promise(r => setTimeout(r, delay));
}
process(n);
}
}
processData(Array(10).keys(), console.log, 3, 1500).then(() => console.log('DONE'));
for (const [ index, el ] of Object.entries(elems)) {
...
for (const [ index, el ] of Array.prototype.entries.call(elems)) {
...
const elems = [...document.getElementsByClassName('one')];
for (const [ index, el ] of elems.entries()) {
...
const elems = document.querySelectorAll('.one');
for (const [ index, el ] of elems.entries()) {
...
Object.values(names.reduce((acc, n) => {
const g = /^\d/.test(n[0]) ? n[0] : /^[А-Я]/i.test(n[0]) ? 'А-Я' : null;
g && (acc[g] = acc[g] || [ g ]).push(n);
return acc;
}, {}))
<app-analytics-chart v-if="analytics.countOrdersByMonth"
<div class="items"></div>
.<select>
<option value="*">Все</option>
<option value=".red">Красные</option>
<option value=".blue">Синие</option>
<option value=".green">Зеленые</option>
</select>
$('select').change(function() {
const selector = this.value;
const $items = $('.items >');
$items.filter(selector).slideDown();
$items.not(selector).slideUp();
});