Помогите решить проблему
Вложений: 1
Выдает TypeError: Cannot set property 'onclick' of null
at index.js:1: :help: |
Вот таким должен быть index.js
function mySort() { let sorty = document.querySelector('.goods-wrap'); for (let i = 0; i < sorty.children.length; i++) { for(let j = i; j < sorty.children.length; j++){ if(+sorty[i].getAttribute('data-price') > +sorty.children[j].getAttribute('data-price')) { replacedNode = sorty.replaceChild(sorty.children[j], sorty.children[i]); insertAfter(replaceNode, sorty.children[i]); } } } } function insertAfter(elem, refElem) { return refElem.parentNode.insertBefore(elem, refElem.nextSibling); } document.addEventListener('DOMContentLoaded', ()=> { document.querySelector('.sorted-price').onclick = mySort; }) |
VictoriaMax,
нет элементов с которыми работает скрипт, скрипт вниз или читать тут |
Часовой пояс GMT +3, время: 19:02. |