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);
const $inputs = $('.input_1');
.Array.from($inputs).forEach(n => console.log(n, n.value ? 'я заполнен' : 'я пуст'));
console.log($inputs.get().some(n => n.value) ? 'кто-то заполнен' : 'все пустые');
console.log($inputs.toArray().every(n => n.value) ? 'все заполнены' : 'кто-то пуст');
console.log(Array.prototype.filter.call($inputs, n => n.value), 'мы заполнены');
console.log([...$inputs.not((i, n) => n.value)], 'мы пустые');
const groupedArr = useMemo(() => {
return Object.values(arr.reduce((acc, { dt, weather }) => {
const [ date, time ] = dt.split(' ');
acc[date] = acc[date] || { date, weather: [] };
acc[date].weather.push({ time, weather });
return acc;
}, {}));
}, [ arr ]);
<ul>{groupedArr.map(n => (
<li>
<h3>{n.date}</h3>
<ul>{n.weather.map(m => (
<li>
{m.time} - {m.weather}
</li>))}
</ul>
</li>))}
</ul>
function getDateInTimeZone(utcOffset, date = new Date()) {
const utcTime = date.getTime() + date.getTimezoneOffset() * 60000;
return new Date(utcTime + utcOffset * 3600000);
}
const moscowDate = getDateInTimeZone(3);
const newYorkDate = getDateInTimeZone(-5);
const tokyoDate = getDateInTimeZone(9);
const digital_root = num => num > 9
? digital_root([...`${num}`].reduce((acc, n) => acc + +n, 0))
: num;
почему 14 часов превратились в 02
как этого избежать?