$('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);
}for (let i = 0; i < document.links.length; i++) {
const n = document.links[i];
if (n.tagName === 'A') {
const title = document.createAttribute('title');
title.value = n.innerHTML;
n.attributes.setNamedItem(title);
}
}
$('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>
const createTreeNode = title => ({ id: null, title, isDirectory: false });
const createTree = data =>
data.reduce((root, { id, name }) => {
(id === 0 ? [] : name.slice(1, -1).split('/')).reduce((parent, title) => {
const c = parent.children = parent.children || [];
parent.isDirectory = true;
return c.find(n => n.title === title) || (c[c.length] = createTreeNode(title));
}, root).id = id;
return root;
}, createTreeNode(data.find(n => n.id === 0).name.slice(1, -1)));
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));