开发者

scroll multiple divs bound to window scroll event

i have the following situation: a div on a page which is displayed as a warning after 10 minutes. after 10 minutes at which point the div is visible it must scroll up and down as the user scrolls the page. Also, i have a user control which can get loaded and be a part of the page which also has a div which scrolls. In a situation where the 2 divs are present on the same page, only the user control div scroll bind is getting called. So when the page i开发者_StackOverflow社区s rendered there exists 2 spots where the following logic is being applied for the scrolls:

$(this).bind('scroll', function(){...});

The logic for the scrolls works fine, it is just the issue of what happens when both divs are present and both need to scroll with the page. Can anyone point me in the right direction of how to have each respective div attached to the scroll event and allow for their own offset values, etc?


ok so chalk up my missing the subtlety of the issue to my naivety of context in the situation. So, for anyone else this may help...

the scrolling div that was getting called correctly was registered with ready by the following:

$(document).ready(function() { setTimeout('onReadyFloatDiv();', 200) }); within the onReadyFloatDiv: $(this).bind('scroll', function(){...} was being used

whereas in the scrolling div that was not working property, it was registered as so: $(document).ready(floatWarning); within floatWarning i was binding like so: $(this).bind('scroll', function(){...}

anyone see the issue here...i sure didnt, i had to change the binding to floatWarning to this: $(window).bind('scroll', function(){...} because the context of this was the document not the window in the binding that was causing me grief.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜