So Im working with electron and in my file "ipcRendererEvent.js" I wrote the following code:
function loadImages (images) {
const imagesList = document.querySelectorAll('ul.list-group')
for (let i = 0, length1 = images.length; i < length1; i++) {
const node = `<li class="list-group-item">
<img class="media-object pull-left" src="${images[i].src}" height="32">
<div class="media-body">
<strong>${images[i].filename}</strong>
<p>${images[i].size}</p>
</div>
</li>`
imagesList.insertAdjacentHTML('beforeend', node)
}
}
And this is the error:
Uncaught TypeError: imagesList.insertAdjacentHTML is not a function
at loadImages (ipcRendererEvents.js:22)
at EventEmitter._electron.ipcRenderer.on (ipcRendererEvents.js:58)
at EventEmitter.emit (events.js:182)
javascript - insertAdjacementHTML is not a function at <anonymous> - Stack Overflow I am trying to place a button after an already existing button on another website. I'm trying to test it out in Chrome console, but can't figure it out.
Element.insertAdjacentHTML() API throws error in chrome 55.0.2883.87 Ask Question Asked4 years, 8 months ago Active1 year, 6 months ago Viewed14k times 12 I found the explaination about the API here, which tells me the second parameter is a string. It's perform normal in firefox.
insertAdjacentElement(position, element) The second parameter should be an element and not html text. E.g. var newDiv = document.createElement('div'); newDiv.style.backgroundColor = 'white'; parentElement.insertAdjacentElement('beforeend',newDiv);
querySelectorAll
returns a NodeList
. You could use querySelector
instead to get the first matching element in the document or you can call insertAdjacentHtml
on an individual element in the list (e.g.: imagesList[0].insertAdjacentHTML
).
The correct notation is insertAdjacentHTML
. You have a small typo :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With