const input = document.querySelector('#textLink');
const buttonSelector = '.link';
document.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
input.value = button.innerText;
}
});
document.querySelectorAll(buttonSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => input.value = e.currentTarget.textContent);
Не работает
есть вариант решения?
Я хочу что бы у инпутов focus срабатывал только по клику
arr.map(n => ({
...n,
items: n.items.filter(m => m.checked).map(m => ({ ...m })),
}))
возможно, computed надо высчитывать?
computed: {
checkedArr() {
return this.arr.map(/* ... */);
},
},
const data = [
{ title: 'a', value: 0 },
{ title: 'b', value: 100 },
{ title: 'c', value: 200 },
];
d3.select('#svg')
.selectAll('g')
.data(data)
.enter()
.append('g')
.append('rect')
.attr('x', d => d.value)
.attr('y', d => d.value)
.attr('width', 50)
.attr('height', 50)
.attr('fill', '#F0A');
Не вижу явного удаления из дом дерева.
.js-select-tabs-head
, неужели этого не видно? Или вы думаете, что там другой элемент, копия? Это не так - можете получить элемент до вызова html, после, сравнить их, увидите, что это один и тот же элемент.$head.html($text.filter('.is-active').clone())
. append('div')
должно быть append('xhtml:div')
.created() {
this.popup = _.throttle(function(state) {
this.show = ({
enter: true,
leave: false,
})[state];
}, 500, {
leading: false,
trailing: true,
});
},
this.popup = _.throttle(show => this.show = !!show, 500, {
leading: false,
trailing: true,
});
<a href="#" @mouseenter="popup(1)" @mouseleave="popup(0)">
this.api = this.api.replace(word, 'BOOM')
this.api = this.api.replace(RegExp(`\\b${word}[a-z]*\\b`, 'ig'), 'BOOM')
Понятно, что можно добавить в форму все виды инпутов и, например, использовать
< component :is='нужный инпут в зависимости от пропса'>
this
из всех методов, которые могут быть не последними в цепочке вызовов:function calc(val) {
const self = Object.create(calc.prototype);
self.val = val;
return self;
}
calc.prototype = {
plus(val) {
this.val += val;
return this;
},
minus(val) {
this.val -= val;
return this;
},
valueOf() {
return this.val;
},
};
+calc(0).plus(1); // 1
+calc(1).plus(1).plus(1); // 3
+calc(1).plus(2).plus(3).plus(4).minus(5); // 5
calc(3).plus(7).minus(2) * 3; // 24
99 + calc(1); // 100
const newArr = arr.slice(-5);
arr.splice(0, arr.length - 5);
const kebab = str => str.replace(/\b([A-Z][a-z]*)+\b/g, n => n.replace(/([A-Z])/g, '-$1').replace(/^-/, '').toLowerCase());
console.log(kebab('KebabCase noKebabCase No_Kebab_Case And FuckDonaldTrump!!')); // "kebab-case noKebabCase No_Kebab_Case and fuck-donald-trump!!"
for (const n of words) {
string = string.replace(RegExp(`\\b${n}\\b`, 'gi'), m => `<a href="#">${m}</a>`);
}
const newString = words.reduce((acc, n) => {
return acc.replace(RegExp(`\\b${n}\\b`, 'gi'), '<a href="#">$&</a>');
}, string);