How can I control the visibility of the :before and :after pseudo elements using JavaScript?
I currently have arrows displayed on both sides of a div. Here is the CSS styling for the arrows:
.edit-wrap:before,
.edit-wrap:after {
@media (max-width: 768px) {
content: '';
....
}
}
I would like to hide these arrows if there is no scroll bar present in the element, and show them otherwise.
var scrollableElement = document.getElementById('scrollable-element');
if(scrollableElement.scrollWidth > scrollableElement.clientWidth){
//display arrows
} else{
//hide arrows
}
Note: I am not utilizing JQuery for this functionality.