I have a <div> on my website, whose CSS attributes I want to change whenever I have scrolled down 10px of the website. How can I do that?
Asked
Active
Viewed 70 times
0
Ry-
- 209,133
- 54
- 439
- 449
Nabil Ghulam
- 191
- 1
- 2
- 12
-
1http://stackoverflow.com/a/15800696/1947286 this should steer you in the right direction – apaul Jun 23 '13 at 02:25
1 Answers
1
what about something like this:
$(document).ready(function() {
$(window).scroll(function() {
var elementTop = $('.someDiv').offset().top;
var position = elementTop- $(window).scrollTop();
if(position == 10){
//do something
}
});
});
I think this may work, i havent tested it yet but give it try..
Also this jquery function should be really helpful, you also check it out: http://api.jquery.com/position/
Jorge Y. C. Rodriguez
- 3,277
- 5
- 34
- 58