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;
}
В консоле выдает Uncaught TypeError: next is not a function
Как выделить при помощи класса текущее число, не выходит
добавляю...
currDay.getMonth() <= month
. Представьте, что следующий месяц - январь, год кончается. Что будет с вашим условием? Правильно, оно останется истинным. Навсегда. Лучше сделать так: проверяете равенство, без "меньше", а while заменяете на do-while - тогда числа предыдущего месяца, формально не подходящие под условие, всё равно будут обработаны, так как тело цикла выполняется до проверки условия.document.querySelectorAll('.restab').forEach((n, i) => {
n.id = `responsivetable${++i}`;
});
// или
for (const [ i, n ] of document.querySelectorAll('.restab').entries()) {
n.attributes.id.value = 'responsivetable' + (i + 1);
}
// или
const elems = document.getElementsByClassName('restab');
for (let i = 0; i < elems.length; i++) {
elems[i].setAttribute('id', 'responsivetable'.concat(-~i));
}
Basket.totalPrice.call(data)
. Но, повторюсь, это безумие. $('.reeder').click(function() {
const $box = $(this).closest('.box').toggleClass('none');
$box.parent().find('.box').not($box).addClass('none');
});
const $boxes = $('.box').on('click', '.reeder', e => {
$(e.delegateTarget).toggleClass('none');
$boxes.not(e.delegateTarget).addClass('none');
});
def printSinglyLinkedList(node):
if node != None:
printSinglyLinkedList(node['next'])
print(node['value'])
printSinglyLinkedList(d)
def reverseSinglyLinkedList(head):
prevNode = None
currNode = head
while currNode != None:
nextNode = currNode['next']
currNode['next'] = prevNode
prevNode = currNode
currNode = nextNode
return prevNode
function onlyOne(checkbox) {
for (const n of document.getElementsByName(checkbox.name)) {
n.checked = n === checkbox ? n.checked : false;
}
}
function onlyOne(checkbox) {
checkbox
.closest('.group')
.querySelectorAll('input[type="checkbox"]')
.forEach(n => n.checked = n.checked && n === checkbox);
}
...как мне правильно написать регулярку для jq метода find(), чтобы он...
data: () => ({
items: [...Array(5).keys()],
}),
methods: {
move(index, step) {
const items = [...this.items];
const newIndex = Math.min(items.length - 1, Math.max(0, index + step));
[ items[index], items[newIndex] ] = [ items[newIndex], items[index] ];
this.items = items;
},
// или
move(index, step) {
const { items } = this;
const newIndex = Math.min(items.length - 1, Math.max(0, index + step));
items.splice(index, 1, items.splice(newIndex, 1, items[index])[0]);
},
// или
move(index, step) {
const newIndex = Math.min(this.items.length - 1, Math.max(0, index + step));
if (index !== newIndex) {
const val = this.items[index];
this.$set(this.items, index, this.items[newIndex]);
this.$set(this.items, newIndex, val);
}
},
},
<div v-for="(n, i) in items">
<input v-model="items[i]">
<button @click="move(i, -1)">вверх</button>
<button @click="move(i, +1)">вниз</button>
</div>