tags:

views:

42

answers:

2

So the problem im having is changing my #scroll top:value with the pixel (px) extension.

#container {
 height:100px;
 overflow:hidden;
}

#scroll {
 position:relative;
 top:0px;
}
<div id="container">

<p>
 <a id="up">Up</a>
</p>

<div id="scroll">up down blah</div>

</div>

$(function(){
  $("#up").hover(function(){
    var topVal = $( 0 + "px");
    $("#scroll").css("top", topVal-10 + "px");
  });
+1  A: 

try this

 $("#up").hover(function(){
   $("#scroll").css("top", "-10px");
 });

this line doesnt make any sens:

var topVal = $( 0 + "px");
antpaw
That did work, thank you very much! Sorry about the random variable I had in.
Starboy
A: 

Pretty sure you don't add the px.

$("#scroll").css("top", topVal-10);

Should do it.

Also, if you are doing what I think you are trying to do (keep scrolling a div on hover) then this thread might be of interest to you, if not, disregard it. http://stackoverflow.com/questions/1897696/continous-mouseover

Gazler
Exactly what I was trying to do, but when I just used "topVal-10" I couldn't get anything to work unless adding the (px). Hence why I was thinking I could just do " topVal-10 + "px" "
Starboy