jQuery css : put a variable in the "top" property
<p>I'm looking for a way to tell the distance from the top of the window and change the css with jQuery if the user makes scroll. I tried things like this and doesn't work: </p>

<pre><code>var topDistance = $('div').offset().top; // distance of the div relative to the top of the window
$('div').css({position: 'absolute',top:topDistance, right:'0px'});
</code></pre>

<p>Is there a way to put the variable in the "top" property of the jQuery css ? I tried the code above and It does not seem to work. Does anyone know how to  improve the code?</p>
