Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!