Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

How to use the scroll bar event on an element

$
0
0

I want the change the background of an element when the scroll bar is beside that element. how to do that? I used 'scroll' event , but didn't work

<div id="skill">This is Skill</div>


var about = document.getElementById('about');
 about.addEventListener('scroll', function() {
 about.style.background='green';
});

like this, when I click on that section the background changes

about.addEventListener('click', function() {
 about.style.background='green'});

Viewing all articles
Browse latest Browse all 67497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>