开发者

Jquery, not changing css top value

开发者 https://www.devze.com 2022-12-18 02:19 出处:网络
So the problem im having is changing my #scroll top:value with the pixel (px) extension. #container { height:100px;

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");
  });


try this

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

this line doesnt make any sens:

var topVal = $( 0 + "px");


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

0

精彩评论

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