Add scroll box property in JavaScript

Add scroll box property in JavaScript


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?


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 = ...... = 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.


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

// (outputBox)