Συζητήσεις » Ανάπτυξη

How to Add a Button on Top of Website without Overlaying Another Element?

§
Δημοσιεύτηκε: 24/12/2019

How to Add a Button on Top of Website without Overlaying Another Element?

How to Add a Button on Top of Website without Overlaying Another Element?

I have tried this script, but no luck

var button = document.createElement("Button"); button.innerHTML = "Title"; button.style = "top:0;right:0;position:absolute;z-index:99999;padding:20px;"; document.body.appendChild(button);

§
Δημοσιεύτηκε: 28/07/2020

try changing position:relative;z-index:1

your problem is with css,not JS

§
Δημοσιεύτηκε: 29/07/2020
Επεξεργάστηκε: 29/07/2020

position:relative; is not going to work.
The code originally posted is working for me. Are you sure that code is being run?

§
Δημοσιεύτηκε: 03/08/2020

send the website,then we can see what's the problem.

I usually use parentElement
document.body.parentElement.appendChild(button);

Δημοσίευση απάντησης

Συνδεθείτε για να δημοσιεύσετε μια απάντηση.