Я так понял, вы предлагаете код, который находится в функции setMarkers() перенести в initializeYandexMap(), я прав?
textareaEl.addEventListener('paste', function() {
setTimeout(() => {
this.value = this.value.split('\n').map((n, i) => {
const line = i + 1;
return `${line}. ${n.replace(RegExp(`^${line}\\. `), '')}`;
}).join('\n');
});
});
Элемент - представленный в примере - это FileInput (кликать нужно на него, что бы вызвать диалог выбора файлов)
const imgs = document.querySelectorAll('img[src*="/test/"]');
это не в dom, а в строке
const div = document.createElement('div');
div.innerHTML = str;
const imgsStr = ''.concat(...[].map.call(
div.querySelectorAll('img[src*="/test/"]'),
n => n.outerHTML
));
const imgsStr = Array
.from(
new DOMParser().parseFromString(str, 'text/html').querySelectorAll('img[src*="/test/"]'),
n => n.outerHTML)
.join('');
const imgsStr = Array.prototype.reduce.call(
document.createRange().createContextualFragment(str).querySelectorAll('img[src*="/test/"]'),
(acc, n) => acc + n.outerHTML,
''
);
мне нужно удалить из этой строки все картинки, которые...
const div = document.createElement('div');
div.innerHTML = str;
const imgs = div.querySelectorAll('img[src*="/test/"]');
for (let i = 0; i < imgs.length; i++) {
imgs[i].outerHTML = '';
}
str = div.innerHTML;
const { body } = new DOMParser().parseFromString(str, 'text/html');
body.querySelectorAll('img[src*="/test/"]').forEach(n => n.remove());
str = body.innerHTML;
const fragment = document.createRange().createContextualFragment(str);
for (const n of fragment.querySelectorAll('img[src*="/test/"]')) {
n.parentNode.removeChild(n);
}
str = Array.from(fragment.childNodes, n => n.outerHTML || n.nodeValue).join('');
Как программно получить индексы Ряда и Ячейки для строки кода
this.showPillarHandler(p.data[индекс Ряда].data[индекс Ячейки]) ?
showMachine={this.showPillarHandler}
.showShelfMachine={showMachine}
.showPlaceMachine={showShelfMachine}
.onClick={() => showPlaceMachine(seat)}
.computed: {
groupedPosts() {
return this.posts.reduce((acc, n) => {
(acc[n.category] = acc[n.category] || []).push(n);
return acc;
}, {});
},
},
При нажатии на название категории хочу выводить посты и соответствующего массива.
categories() {
return Object.keys(this.groupedPosts);
},
data: () => ({
activeCategory: null,
...
<button
v-for="n in categories"
v-text="n"
:class="{ active: n === activeCategory }"
@click="activeCategory = n"
></button>
<div v-if="activeCategory">
<div v-for="n in groupedPosts[activeCategory]" class="post">
...
Я тут начинаю изучать php с фреймворка yii2
function onlyOne({ value, dataset: { group } }) {
document.querySelectorAll(`[data-group="${group}"]`).forEach(n => {
n.checked = n.checked && n.value === value;
});
}
todoList.forEach(function(element) {
document.getElementById('out').innerHTML += '<p>'+element+'</p>';
});
document.getElementById('out').innerHTML = todoList.map(n => `<p>${n}</p>`).join('');
const div = document.createElement('div');
div.innerHTML = html;
div.querySelectorAll('a[href*="/test/"]').forEach(n => n.outerHTML = '');
html = div.innerHTML;
const { body } = new DOMParser().parseFromString(html, 'text/html');
body.querySelectorAll('a[href*="/test/"]').forEach(n => n.remove());
html = body.innerHTML;
const fragment = document.createRange().createContextualFragment(html);
fragment.querySelectorAll('a[href*="/test/"]').forEach(n => n.parentNode.removeChild(n));
html = Array.from(fragment.childNodes, n => n.outerHTML || n.nodeValue).join('');
function sort(desc, attr) {
const select = document.querySelector('#search-sort-field');
select.append(...Array
.from(select.children, n => [ n, n.getAttribute(attr) * (desc ? 1 : -1) ])
.sort((a, b) => a[1] - b[1])
.map(n => n[0])
);
}
const tbody = document.querySelector('#table tbody');
// или
const [ tbody ] = document.getElementById('table').tBodies;
tbody.innerHTML = arr
.map(n => `
<tr>
<td><a href="${n.link}">${n.city}</a></td>
<td>${n.country}</td>
</tr>`)
.join('');
for (const n of arr) {
const tr = tbody.insertRow();
const a = document.createElement('a');
a.href = n.link;
a.text = n.city;
tr.insertCell().append(a);
tr.insertCell().textContent = n.country;
}