【发布时间】:2013-04-05 11:23:48
【问题描述】:
如何使用存储在 var height 中的值作为 margin-top 的值?
<script>
$(document).ready(function(){
var height = $(window).height() / 2;
$("a").click(function(){
$("#loader").css({"margin-top:", ***height});
});
});
</script>
提前谢谢...
【问题讨论】:
-
删除
***? -
去掉***...否则你的代码是正确的
-
position也可能有问题:您不能在任何块上设置 margin-top。
标签: javascript jquery css