$('.select-list').change(function() {
const selected = $(':checked', this)
.parent()
.get()
.map(n => $(n).text().trim())
.join(', ');
$('.selected-name--filter').text(selected || 'Любой');
}).change();
const select = document.querySelector('.select-list');
select.addEventListener('change', function() {
const selected = Array
.from(this.querySelectorAll(':checked'), n => n.parentNode.textContent.trim())
.join(', ');
document.querySelector('.selected-name--filter').textContent = selected || 'Любой';
});
select.dispatchEvent(new Event('change'));
this.setState(({ clientData }) => ({
clientData: {
...clientData,
active: !clientData.active,
},
}));
$('a').attr('title', function() {
return $(this).text();
});
document.querySelectorAll('a').forEach(n => n.title = n.innerText);
for (const n of document.getElementsByTagName('a')) {
n.setAttribute('title', n.textContent);
}
$('select').change(function() {
$('button').prop('disabled', $(this).val() === '0');
});
document.querySelector('select').addEventListener('change', function() {
document.querySelector('button').disabled = this.value === '0';
});
data: () => ({
opened: null,
blocks: [
{ id: 1, content: 'Я первый' },
{ id: 2, content: 'А я второй' },
{ id: 3, content: 'Третьим буду' },
],
}),
<a v-for="b in blocks" @click="opened = b">открыть {{ b.id }} блок</a>
<div v-if="opened" :class="`block-${opened.id}`">
<a @click="opened = null">Скрыть блок</a>
<div class="content">{{ opened.content }}</div>
</div>
function getTree(data) {
let root = data.find(n => n.id === 0);
root = { title: root.name.slice(1,-1), id: root.id };
data.filter(n => n.id !== 0).forEach(item => {
const node = item.name.slice(1, -1).split('/').reduce((parent, title) => {
if (!parent.children) {
Object.assign(parent, { children: [], isDirectory: true });
}
let child = parent.children.find(m => m.title === title);
if (!child) {
child = { title };
parent.children.push(child);
}
return child;
}, root);
Object.assign(node, { id: item.id, isDirectory: !!node.isDirectory });
});
return root;
}
filters: {
price: val => val.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1 ").replace('.', ','),
},
td {{ product.price | price }}
price: val => val.toLocaleString('ru', {
style: 'currency',
currency: 'RUB',
}),
onTranslated() {
const $firstActive = this.$element.find('.owl-item.active:eq(0)');
},
.on('translated.owl.carousel', function() {
const $firstActive = $(this).find('.owl-item.active:eq(0)');
})
String days[] = { "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс" };
for (int day = 0; day < 7; day++) {
System.out.print("День недели: " + days[day] + " Часы: ");
...
:class="[ { infoItem.fadeClass: !infoItem.isVisible }, infoItem.defaultClass ]"
[infoItem.fadeClass]
:to="{ path: '/field_of_activity', props: { messageId: 1}}"
props: route => ({ ...route.query })
.props: route => ({ ...route.query, ...route.params })
при выборе меньше 100 кнопка submit (отправка формы) не появлялась либо не была активна?
<button :disabled="notAllGoalsAchieved">submit</button>
methods: {
notAchieved(goal) {
return goal.tasks.reduce((acc, n) => acc + n.value, 0) !== 100;
},
},
computed: {
notAllGoalsAchieved() {
return this.goals.some(this.notAchieved);
},
},
показывать что конкретная цель не до конца проставлена(каким нибудь текстовым сообщением)
<span v-show="notAchieved(g)">не достигнута</span>
const input = document.querySelector('input');
const button = document.querySelector('button');
const num = 6;
input.addEventListener('input', e => {
button.disabled = e.target.value % num;
});
button.addEventListener('click', () => {
if (input.value % num) {
alert('такого нам не надо, пробуй ещё');
}
});
input.addEventListener('change', ({ target: t }) => {
t.value = Math.max(0, (t.value / num | 0) * num);
});
<button data-step="-1">-</button>
<button data-step="+1">+</button>
document.querySelectorAll('[data-step]').forEach(function(n) {
n.addEventListener('click', this);
}, e => input.value = Math.max(0, +input.value + num * e.target.dataset.step));