Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
How to insert a new element after an existing one with JavaScript

I have this link and I want to insert an new element after the 180 price tag as shown here

My current code:

window.addEventListener('load', function () {
    setTimeout(function () {
        var itemPrice = document.getElementById("gsItemPrice").innerText.replace('¥', '').replace('.00', '') * 0.15;
    console.log("$" + itemPrice)
    var element = document.createElement('p');
    element.style.fontSize = '20px';
    element.innerHTML = "$" + itemPrice
    
    function insertAfter(referenceNode, newNode) {
        referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
    }

    var findPart = document.getElementsByClassName('item-pri');
    insertAfter(findPart, element);

    }, 2000);
    
  })

Error: Uncaught TypeError: Cannot read properties of undefined (reading 'insertBefore')

Notes: The function timeout is set since the site uses a function to scrape the price of the item

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda