<div class="range">
<input type="range" min="0" max="100" step="1" value="20">
<input type="text" value="20">
</div>
const range = document.querySelector('.range [type="range"]');
const text = document.querySelector('.range [type="text"]');
range.oninput = () => text.value = range.value;
text.oninput = () => range.value = text.value;
// или
document.querySelector('.range').addEventListener('input', e => {
e.currentTarget.querySelectorAll('input').forEach(n => n.value = e.target.value);
});
// или
const inputs = document.querySelectorAll('.range input');
const onInput = e => inputs.forEach(n => n.value = e.target.value);
inputs.forEach(n => n.addEventListener('input', onInput));
$('.add-task').click(function() {
const task = $('.input-task').val();
if (!task) {
alert('пусто');
return false;
}
$('.todos-container').append(`
<div class="todo-container">
<label>
<b class="task-text">${task}</b>
<input class="toggle-task" type="checkbox">
</label>
<button class="del-task">delete</button>
</div>
`);
$('.input-task').val('');
});
$('.todos-container')
.on('change', '.toggle-task', function() {
$(this)
.closest('.todo-container')
.find('.task-text')
.toggleClass('task-done', this.checked);
})
.on('click', '.del-task', function() {
$(this).closest('.todo-container').remove();
});
.task-done {
text-decoration: line-through;
}
data: () => ({
showChars: 0,
...
}),
computed: {
typedString() {
return this.string.slice(0, this.showChars);
},
},
<h2>{{ typedString }}</h2>
mounted() {
const intervalID = setInterval(() => {
if (++this.showChars === this.string.length) {
clearInterval(intervalID);
}
}, 50);
},
Что нужно добавить?
function createTree(arr, idKey, parentKey) {
const tree = {};
arr.forEach(n => tree[n[idKey]] = Object.assign({}, n));
return Object.values(tree).reduce((acc, n) => {
const parent = tree[n[parentKey]];
(parent ? parent.children = parent.children || {} : acc)[n[idKey]] = n;
return acc;
}, {});
}
const tree = createTree(data, 'id', 'parent_id');
.size-otherBtn {
display: grid;
grid-template-columns: 50px 50px 50px 50px;
grid-template-rows: auto;
grid-template-areas:
"mSize lSize xlSize xxlSize"
"sizeGuide sizeGuide shopNow shopNow";
}
$teacherID = чему-то там равен, неважно...
$itemsByTeacherID = [];
foreach ($days as $day) {
foreach ($day['day_items'] as $item) {
if ($item['teacher'] === $teacherID) {
$itemsByTeacherID[$day['day']][] = $item;
}
}
}
$('input').on('focus blur', function(e) {
$(this).toggleClass('active', e.type === 'focus');
});
const onFocus = e => e.target.classList.toggle('active', e.type === 'focus');
document.querySelectorAll('input').forEach(n => {
n.addEventListener('focus', onFocus);
n.addEventListener('blur', onFocus);
});
$brands = array_filter($brands, function($n) {
return isset($n['alias']);
});
data: () => ({
activeComponent: null,
components: [
{ name: 'component-1', label: '#1' },
{ name: 'component-2', label: 'а я второй' },
{ name: 'component-3', label: 'третьим буду' },
],
}),
v-model
:<select v-model="activeComponent">
<option v-for="n in components" :value="n.name">{{ n.label }}</option>
</select>
<component v-if="activeComponent" :is="activeComponent"></component>
document.querySelector('table').addEventListener('input', function(e) {
e.target.style.backgroundColor =
e.target.innerHTML имеет какое надо значение
? 'lime'
: 'red';
});