1

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
  • never mind yet my above comment may I ask what's this $( 0 + "px");? Commented Jan 27, 2010 at 17:07

2 Answers 2

5

try this

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

this line doesnt make any sens:

var topVal = $( 0 + "px");
Sign up to request clarification or add additional context in comments.

1 Comment

That did work, thank you very much! Sorry about the random variable I had in.
0

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. Continuous mouseover

1 Comment

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" "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.