首页javascripttopjQuery Style - 如何设置顶部属性值

jQuery Style - 如何设置顶部属性值

我们想知道如何设置顶部属性值。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    var var_top = 300;
    $( ".ball" ).css( { top : "+=" + var_top + 'px'});
});
</script>
</head>
<body>
  <div style="position: relative">
    <div style="position: absolute; top: 200px" class="ball">
      something</div>
  </div>
</body>
</html>