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.toPrimitivecorrectly 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').
<input type="text" value="0.00">document.querySelector('input').addEventListener('keypress', function(e) {
e.preventDefault();
this.value = this.value.replace(/(0)(?!.*\1)/, e.key);
});
const index = arr.findIndex(n => n.id === id);
if (index !== -1) {
arr.splice(index, 1);
}const newArr = arr.filter(n => n.id !== id);for (let i = 0; i < arr.length; i++) {
if (arr[i].id === id) {
for (let j = i--; ++j < arr.length; arr[j - 1] = arr[j]) ;
arr.pop();
}
}arr.reduceRight((_, n, i, a) => n.id === id && a.splice(i, 1), null);arr.splice(0, arr.length, ...arr.filter(n => n.id !== id));arr.length -= arr.reduce((acc, n, i, a) => (
a[i - acc] = n,
acc + (n.id === id)
), 0);
<input type="range" min="20" max="200" value="100">
<img src="...">document.querySelector('input').addEventListener('input', function() {
document.querySelector('img').style.filter = `brightness(${this.value}%)`;
});