How to add class when page scroll reach at specific id?

Have a look at scroll spy:

Here is a template I knocked up a few weeks back that will give you an idea of how to do it..