I'm putting a DIV inside a parent DIV with the overflow-x set to scroll.
When scrolling is not needed I want to display none on a message div. When it's needed I want to show this DIV.
How can I achieve this?
function myFunction() { var x = 0; var parentWidth = document.getElementById("myDIV").clientWidth; var x = document.getElementById("thisDIV").querySelectorAll(".awiderDIV"); if (x[0].clientWidth > parentWidth){ document.getElementById("scroll").style.display = "flex"; } else { document.getElementById("scroll").style.display = "none"; } }
Try this div { overflow: visible | hidden | scroll | auto | inherit }