function GetFaqAriaExpand(el) {
var fa = $(el).attr('aria-expanded');
...
var fa = GetFaqAriaExpand(this);var fa = GetFaqAriaExpand.call(this);
$('.radio-input').parent('p').text((i, text) => text.replace('Какой-то ', ''))
$(this).parent('.card-header')card-header? - если нет, вызывайте parent без параметра. Или может быть класс есть, но элемент не родительский, а находится выше? - тогда замените parent на closest.
Promise.all(rcs.map((residential, i) => {
return new Promise(resolve => {
setTimeout(() => {
...
resolve();
}, i * 50);
});
}).then(() => {
...
});async setMarkers(rcs) {
for (const residential of rcs) {
await new Promise(resolve => setTimeout(resolve, 50));
...
}
...
}
const sort = {
str: (a, b) => a.text().localeCompare(b.text()),
num: (a, b) => parseInt(a.text(), 10) - parseInt(b.text(), 10),
};<button class="sort" data-field="age" data-type="num">Сортировать по возрасту</button>
<button class="sort" data-field="name" data-type="str">Сортировать по имени</button>$('.sort').click(function() {
const
$this = $(this),
data = $this.data(),
compare = sort[data.type],
field = `.${data.field}`,
order = +data.order || 1;
$('.block')
.sort((a, b) => order * compare($(field, a), $(field, b)))
.appendTo('.cont');
$this.data('order', order * -1);
});
const elems = document.querySelectorAll('.itog_price');elems.forEach((n, i) => n.append(price[i]));
// или
for (const [ i, n ] of elems.entries()) {
n.innerText = price[i];
}
// или
for (let i = 0; i < elems.length; i++) {
elems[i].textContent = price[i];
}
// или
(function next(i, n = elems.item(i)) {
n && (n.appendChild(new Text(price[i])), next(-~i));
})(0);
$list.find('input').click(e => e.stopPropagation());if (!$(e.target).is('input')) {
$list.hide();
}
.slice(1) там, где работаете со строками таблицы. Т.е., вместо$('#data tbody tr').hide();
$('#data tbody tr').slice(0, rowsShown).show();$('#data tbody tr').slice(1).hide().slice(0, rowsShown).show();$('#data tbody tr').css('opacity',...$('#data tbody tr').slice(1).css('opacity',...
str.match(/rgb\(.*\)/).pop().match(/\d+/g)str.match(/rgb\((.*)\)/).pop().split(', ')
projectTechnologies.innerHTML = technologyHandler(dataTechnologies).map((el) => el);projectTechnologies.innerHTML = technologyHandler(dataTechnologies).map(n => n.outerHTML).join('');
// или
technologyHandler(dataTechnologies).forEach(n => projectTechnologies.appendChild(n));
// или
for (const n of technologyHandler(dataTechnologies)) {
projectTechnologies.insertAdjacentElement('beforeend', n);
}
// или
projectTechnologies.append(...technologyHandler(dataTechnologies));technologyHandler следующим образом:const technologyHandler = str => str
.split(' ')
.map(n => `<p class="project_technologies-item">${n}</p>`)
.join('');
// или
const technologyHandler = str =>
str.replace(/ ?(\S+)/g, '<p class="project_technologies-item">$1</p>');map после её вызова:projectTechnologies.innerHTML = technologyHandler(dataTechnologies);
const digits = Object
.entries([...`${num}`].reduce((acc, n) => (acc[n] = -~acc[n], acc), {}))
.reduce((acc, n) => (~-n[1] && acc.push(+n[0]), acc), []);const digits = (function get(num, count) {
num && (count[num % 10]++, get(Math.floor(num / 10), count));
return count;
})(num, Array(10).fill(0))
.map((n, i) => n > 1 && i)
.filter(n => n !== false);const digits = Array
.from(String(num), Number)
.filter((n, i, a) => i !== a.indexOf(n))
.filter((n, i, a) => i === a.indexOf(n));const digits = (('' + num)
.match(/\d/g)
.sort()
.join('')
.match(/(\d)\1+/g) || [])
.map(n => n[0] | 0);
const values = [ 'text', 'move', 'lols' ];
const selector = values.map(n => `[data-cmd="${n}"]`).join(', ');
const elements = document.querySelectorAll(selector);const hide = el => el.style.display = 'none';
// или
const hide = el => el.style.setProperty('visibility', 'hidden');
// или
const hide = el => el.style.cssText += 'opacity: 0';
// или
const hide = el => el.setAttribute('style', 'transform: scale(0)');
// или
const hide = el => el.hidden = true;elements.forEach(hide);
// или
for (const n of elements) {
hide(n);
}
// или
for (let i = 0; i < elements.length; i++) {
hide(elements[i]);
}
// или
(function next(i, n = elements.item(i)) {
n && (hide(n), next(-~i));
})(0);
$('.count').on('input', e => $('.game_iframe').width(e.target.value));document.querySelector('.count').addEventListener('input', function() {
document.querySelector('.game_iframe').style.width = `${this.value}px`;
});