Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
Uncaught TypeError: Cannot read properties of undefined (reading 'getAttribute')

have error Uncaught TypeError: Cannot read properties of undefined (reading 'getAttribute')

I have a website that needs to use filters. Sort by price. But displays an error

enter image description here

enter image description here

const big_content = document.querySelector('#big_content');
document.querySelector('#sort_low').onclick = function() {
                      low__high('data-price')
}
document.querySelector('#sort_high').onclick = function() {
                      high__low('data-price')
};

function low__high(sortType) {
 const big_content = document.querySelector('#big_content');
       for (let i = 0; i < big_content.children.length; i++) {
            for (let j = i; i < big_content.children.length; j++) {
    if (+big_content.children[i].getAttribute(sortType) > +big_content.children.length[j].getAttribute(sortType)) {
                                            replaceNode = big_content.replaceChild(big_content.children[j], big_content.children[i])
                                            insertAfter(replaceNode, big_content.children[i])
                                        }
                                    }
                                }
                                console.log('Sort by price: low to high');
                            }

                            function high__low(sortType) {
                                const big_content = document.querySelector('#big_content');

                                for (let i = 0; i < big_content.children.length; i++) {
                                    for (let j = i; i < big_content.children.length; j++) {
                                        if (+big_content.children[i].getAttribute(sortType) < +big_content.children.length[j].getAttribute(sortType)) {
                                            replaceNode = big_content.replaceChild(big_content.children[j], big_content.children[i])
                                            insertAfter(replaceNode, big_content.children[i])
                                        }
                                    }
                                }
                                console.log('Sort by price: high to low');
                            }

                            function insertAfter(elem, refElem) {
                                return refElem.parentNode.insertBefore(elem, refElem.nextSibling)
                            }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda