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

198
Vistas
CTA button placement in the bottom of page using Javascript

I have to edit a website using just vanilla javascript. I have to overlay a dropdown menu with a CTA button that when pressed activates said menu.

I tried hiding the dropdown menu by setting css property to hidden, and added a button with "on click" event to make the menu visible again (all of this on Chrome dev console), but when adding the button element to document body it appends at the very end of page.

I tried using insertBefore but i cannot get it to work that way. Any better suggestions/help on how to approach this problem , or what I'm doing wrong in the insertBefore statement would be greatly appreciated.

const btn = document.createElement('Button');
btn.innerText='BUTTON';
btn.addEventListener('click',() =>{ BookingFormContent.style.visibility = 'visible';}); 
document.body.insertBefore(BookingForrm,btn);

error statement that follows is :

Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node. at :1:15

this is my first time messing with DOMs, so i might not be doing stuff right somewhere else.

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