document.querySelector('.selectTime').addEventListener('change', function() {
const values = Array.from(this.querySelectorAll('select'), n => n.value);
values[0] = `${-~values[0] % 24}`;
document.querySelector('куда там вам надо записать время').innerText = values
.map(n => n.padStart(2, 0))
.join(':');
});
const getAndDel = (obj, ...keys) =>
keys.reduce((acc, n) => (
acc[n] = obj[n],
delete obj[n],
acc
), {});
const obj1 = { a: 1, b: 2, c: 3, d: 4 };
const obj2 = getAndDel(obj1, 'a', 'b');
const obj3 = getAndDel(obj1, 'c');
console.log(obj1); // {d: 4}
console.log(obj2); // {a: 1, b: 2}
console.log(obj3); // {c: 3}
if(axis === "x") ctx.moveTo((position + x0), yMax); ctx.lineTo((position + x0), (y0 - dec)); ctx.stroke(); if(axis === "y") ctx.moveTo(x0, (yMax - position)); ctx.lineTo(xMax, (yMax - position)); ctx.stroke();
this.insertAdjacentHTML('afterend', `
<select>${arr.map(n => `
<option value="${n.value}" ${n.selected ? 'selected' : ''}>
${n.text}
</option>`).join('')}
</select>
`);
const select = document.createElement('select');
arr.forEach(n => select.appendChild(Object.assign(document.createElement('option'), n)));
this.insertAdjacentElement('afterend', select);
const select = document.createElement('select');
select.append(...arr.map(n => new Option(n.text, n.value, false, n.selected)));
this.after(select);
const getWidths = data =>
[].concat(data || []).reduce((acc, n) => {
if (n.hasOwnProperty('width')) {
acc.push(n.width);
}
acc.push(...getWidths(n.columns));
return acc;
}, []);
function getDatesIntervalStr(dates) {
const dateParts = d => ({ year: d.year(), month: d.format('MMMM') });
const start = dateParts(dates[0]);
const end = dateParts(dates[dates.length - 1]);
if (start.year !== end.year) {
return `${start.month} ${start.year} - ${end.month} ${end.year}`;
} else if (start.month !== end.month) {
return `${start.month} - ${end.month} ${end.year}`;
} else {
return `${end.month} - ${end.year}`;
}
}
<div class="colors">
<div class="color" data-color="blue">Blue</div>
<div class="color" data-color="red">Red</div>
<div class="color" data-color="pink">Pink</div>
</div>
let selectedTD = null;
const $colors = $('.colors').on('click', '.color', function() {
$(selectedTD).css('backgroundColor', this.dataset.color);
selectedTD = null;
$colors.hide();
}).hide();
$('table').on('click', 'td', function() {
selectedTD = selectedTD === this ? null : this;
$colors.toggle(!!selectedTD);
});
...или есть какой-то скрытый от меня смысл?
It will handle cases withSymbol.toPrimitive
correctly and throw correctly if template literal expression is aSymbol()
. See babel/babel#5791.
this.currentImg = Math.min(+this.currentImg + 1, this.maxImages - 1);
$('#results').on('change', 'tr', function(e) {
console.log(e, $(this).data('xxx'));
});
function displayLine(data) {
$('#results').append($(`
<tr>
<th scope="row">${importLines.length}</th>
<td><input class="checkbox" type="checkbox"></td>
<td>${data[0]}</td>
<td>${data[2]}</td>
<td>${data[11]}</td>
<td id="status-${data[0]}"><b><span style="color: orange">PENDING</span></b></td>
</tr>
`).data('xxx', data));
}
arr.propertyIsEnumerable(length) // => true
$(document).on('click', '.sandwitch', function () {
if ($(window).width() < 520) {
$(this).toggleClass('sandwitch--active');
$('.main-menu-list').slideToggle();
}
});
state = { field: newField, currentPlayer: newPlayer };
Object.assign(state, { ... })
. function foo(...args) {
console.log(args[N]);
}
function foo() {
console.log(arguments[N]);
}
function foo(...{ [N]: x }) {
console.log(x);
}
const cards = Array.from(
document.querySelectorAll('[data-component="card"]'),
n => new Card(n)
);
constructor(el) {
if (typeof el === 'string') {
return Array.from(document.querySelectorAll(el), n => new Card(n));
}
// дальше всё по-старому
const cards = new Card('[data-component="card"]');
Подозреваю, что виноват ".parents()"
.closest('.block')
или .parent().next('.slider-btns')
.