Не могу всавить строку в элемент
var sibling = document.querySelector('[data-first="1"]')
console.log(sibling )
// <div class="day col slot colorRow" data-itemid="1" data-date="1699077600000" style="background: rgb(250, 235…: 0px; border-top: 0px;" data-children="" data-first="1" onclick="setSlot(this)">
console.log(sibling.children)
//
HTMLCollection { 0: span.price-hover.first, length: 1 }
length: 0
<prototype>: HTMLCollectionPrototype { item: item(), namedItem: namedItem(), length: Getter, … }
console.log(sibling.children[0])
// <span class="price-hover first">
console.log(sibling.children[0].innerHTML)
// 600
Как вставить в sibling.innerHTML строку? Всё это получаю при клике на соседний элемент |
Вроде разобрался. Сделал так
var arr = Array.from(sibling.children) arr[0].innerHTML = '...' sibling.appendChild(arr) Правда ошибка вылазиет Uncaught TypeError: Node.appendChild: Argument 1 does not implement interface Node. Но если так sibling.appendChild(arr[0]), то не работает |
Ошибка в коде была. Решено)
|
Что куда вставлять так и не ясно.
В <span class="price-hover first">? Перед <span class="price-hover first">? Может с помощью insertAdjacentHTML надо было вставлять? |
sibling.firstElementChild.append(document.createTextNode('some text'));
|
Цитата:
sibling.firstElementChild.append('some text')
|
| Часовой пояс GMT +3, время: 20:40. |