str.replace(/.{4}(?!$)/g, '$&-')
// или
str.match(/.{1,4}/g).join('-')
// или
str.split(/(?<=^(?:.{4})+)/).reduce((acc, n) => acc + (acc && '-') + n, '')
// или
''.concat(...[...str].map((n, i) => !i || i % 4 ? n : `-${n}`))
// или
Array.from(
{ length: Math.ceil(str.length / 4) },
(n, i) => str.slice(i * 4, (i + 1) * 4)
).join`-`
const items = document.querySelectorAll('.yourself-item__title');
const height = `${Math.max(...Array.from(items, n => n.clientHeight))}px`;
items.forEach(n => n.style.height = height);
.accordion__grandchild__item
, а переключаете видимость у родительских элементов - .accordion__grandchild__group
. Надо как-то устранить это печальное несоответствие. v-model
. flex-direction: column;
justify-content: space-around;
$('select').change(function() {
const v = this.value;
$('.sum').text($(`.element${v === '*' ? '' : `.${v}`}`).length);
});
document.querySelector('select').addEventListener('change', e => {
const v = e.target.value;
const s = '.element' + (v === '*' ? '' : '.' + v);
document.querySelector('.sum').textContent = document.querySelectorAll(s).length;
});
<select data-prop="type">
<option hidden></option>
<option value="type1">hello, world!!</option>
<option value="type2">fuck the world</option>
<option value="type3">fuck everything</option>
</select>
<br>
<input placeholder="name1" data-prop="name">
<input placeholder="name2" data-prop="name">
<input placeholder="name3" data-prop="name">
<br>
<input placeholder="url1" data-prop="url">
<input placeholder="url2" data-prop="url">
<input placeholder="url3" data-prop="url">
<br>
<input class="value" disabled>
<input class="value" disabled>
<input class="value" disabled>
const getValues = prop =>
Array.from(document.querySelectorAll(`[data-prop="${prop}"]`), n => n.value);
document.addEventListener('input', e => {
if (!e.target.dataset.prop) {
return;
}
const type = getValues('type')[0];
const names = getValues('name');
const urls = getValues('url');
document.querySelectorAll('.value').forEach((n, i) => {
n.name = n.value = `xxx[${type}][${names[i]}][${urls[i]}]`;
});
});
state.sec
.if (item.innerText === currentPage) {
item.innerText == currentPage
+item.innerText === currentPage
document.body.insertAdjacentHTML('beforeend', `
<div class="container">
<table>
<thead>
<tr>${keys.map(k => `
<th>${k}</th>`).join('')}
</tr>
</thead>
<tbody></tbody>
</table>
<div class="pagination"></div>
</div>
`);
const tableEl = document.querySelector('.container table');
const paginationEl = document.querySelector('.container .pagination');
paginationEl.addEventListener('click', ({ target: t }) =>
t.matches('a') && showPage(+t.textContent)
);
function showPage(page) {
paginationEl.innerHTML = Array
.from(
{ length: Math.ceil(data.length / rows) },
(_, i) => `<a${-~i === page ? ' class="active"' : ''}>${-~i}</a>`)
.join('');
tableEl.tBodies[0].innerHTML = data
.slice(~-page * rows, page * rows)
.map(n => `
<tr>${keys.map(k => `
<td>${n[k]}</td>`).join('')}
</tr>`)
.join('');
}
showPage(1);
$('.input_1').each((i, n) => console.log(n, n.value ? 'я заполнен' : 'я пуст'));
console.log($('.input_1').get().some(n => n.value) ? 'кто-то заполнен' : 'все пустые');
console.log($('.input_1').toArray().every(n => n.value) ? 'все заполнены' : 'кто-то пуст');
console.log(Array.from($('.input_1')).filter(n => n.value), 'мы заполнены');
console.log([...$('.input_1').not((i, n) => n.value)], 'мы пустые');