Javascript function that checks if the textarea scroll has been moved

Asked

Viewed 277 times

3

How to make a Javascript function that checks whether the scroll of a textarea (this textarea has a disclaimer) has been moved.

If the user moves the scroll, enable a div with the continuation of a registration form.

Follows the code:

<script>
document.getElementById('id').onscroll = function(){
   alert('foi movido');
}
</script>

1 answer

6


In pure Javascript

window.onload=function(){
    document.getElementById('id').onscroll = function(){
       alert('foi movido');
    }
}

Or you can also use this command from jQuery - .scroll

$("#id").scroll(function() { alert('Foi movido') });
  • 1

    Thank you very much Silvio Andorinha.

  • He didn’t mention jquery, just javascript. It was interesting to complete his reply by inserting an example with pure javascript.

  • @Filipe ok, I’m doing some tests here and I already complement the answer

  • I am zero in javascript knowledge. It didn’t work here

  • @Geraniel edit your question and post the code of your textarea please..

  • http://jsfiddle.net/an9Na/ a look here’s working.

  • @Geraniel edited the question using the window.onload take the test again

  • @Geraniel yes it is because of the window.onload take the test with the change I made in response.

  • 1

    show stayed tri http://jsfiddle.net/nF7Qm/ . Thank you very much

  • @Geraniel I am happy to help, as you are new on the site I advise you to take a look at this page

  • @Geraniel and if the answer helped you, please don’t forget to mark it as sure ;)

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.