Sarah G
Sarah G

Reputation: 3

How to make a fixed div box using javascript ONLY (no css, jquery, html)

I've been searching for a way to do this all day but have had no luck. My apologies if I missed a post about this somehow. I'm working with Qualtrics currently and am trying to code to have a textbox with the instructions scrolling down the page with the participant as they fill out the survey. I have never worked with javascript coding before today, I am only familiar with basic html. From what I have found today I believe I need to code for a fixed div box. I did find codes, but they all had elements of html or css involved, which the qualtrics program does not allow for. In qualtrics you must code within the question itself. Is there anyway I can code for this using only javascript? Thank you so much in advance!

Upvotes: 0

Views: 1616

Answers (1)

Markus
Markus

Reputation: 159

Do you mean something like this?

var box = document.createElement('div');
box.style.position = 'fixed';
box.style.top = '100px';
box.style.right = '10px';
box.style.width = '200px';
box.style.height = '100px';
box.style.color = 'black';
box.style.background = 'lightblue';
box.style.padding = '20px';
box.innerText = 'Hello world';
document.body.appendChild(box);

Upvotes: 3

Related Questions