Add scroll box property in JavaScript

Add scroll box property in JavaScript
0

#1

Is there a way i can add the property of scroll to a Div in JS?

If i had Div that contained, for instance, a h1. If the length of the h1 text is greater then like 12, could i change the div around it and add a scroll?


#2

You try overflow: scroll? Best to do in CSS but I believe with dot notation on the selected element you could do it.

let div = ......
dev.style.overflow = scroll

You’ll also need to set the height of the div to a fixed pixel amount to make it work. Good luck and let us know if it works.


#3

I tried overflow: scroll just to test if it works, and got this:

// https://codepen.io/Mike-was-here123/pen/PQOYjB (outputBox)