I'm attempting to implement something similar in WordPress - I want a div containing an advertisement to initially start 300px down the page, then scroll up with the page until it reaches the top, and finally stay there if the user continues to scroll down. Here is the example I found:
I tried recreating it in an html file, but even though everything seems fine, it just won't work:
If you look at the "Similar Questions" box on the right and scroll down, that's exactly what I'm aiming for.
I believe I have followed all the steps correctly, but for some reason, the javascript isn't functioning. When I directly add the jQuery code to the header instead of linking to a separate js file like this:
<script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript">
it doesn't work as expected.
Any suggestions on what could be causing this issue?
Here's a snippet from my header:
<script type='text/javascript' src='http:/www.altesc.net/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
<script type="text/javascript">
//<![CDATA[
$(window).load(function(){
$(document).scroll(function() {
var useFixedSidebar = $(document).scrollTop() > 330;
$('.adscrollleft').toggleClass('fixedSidebar', useFixedSidebar);
});
});//]]>
</script>