mirror of https://gitlab.com/curben/blog
refactor: replace for loop with forEach()
https://stackoverflow.com/a/34832466/9645167
This commit is contained in:
parent
3b4172119b
commit
3dfc57dbbe
|
@ -9,13 +9,13 @@ searchClick.onclick = function() {
|
|||
// Add "Copy" button to code snippet
|
||||
const code = document.getElementsByClassName('code')
|
||||
|
||||
for (let i = 0; i < code.length; i++) {
|
||||
Array.from(code).forEach((element) => {
|
||||
const button = document.createElement('button')
|
||||
button.className = 'copy-button'
|
||||
button.textContent = 'Copy'
|
||||
|
||||
code[i].appendChild(button)
|
||||
}
|
||||
element.appendChild(button)
|
||||
})
|
||||
|
||||
/*
|
||||
* Copy button and Cloudinary functions.
|
||||
|
|
Loading…
Reference in New Issue