注意用法animate和alert

来源:互联网 发布:网络平台招代理商协议 编辑:程序博客网 时间:2024/05/16 12:25

1.HTML 元素默认是静态定位,且无法移动。

如需使元素可以移动,请把 CSS 的 position 设置为 relative 或 absolute。

 

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#start").click(function(){
  $("#box").animate({left:"100px"},"slow");
  $("#box").animate({fontSize:"3em"},"slow");
  });
});
</script>
</head>
 
<body>

<p><a href="#" id="start">Start Animation</a></p>

<div id="box"
style="background:#98bf21;height:100px;width:200px;position:relative">
HELLO

</div>
 
</body>
</html>

 

2. alert

 在作为其他函数或者被“”包括着的时候alert里面的字符串要用单引号。例如 document.write(“alert('要用单引号')”)

单独用的时候alert中的要用双引号,alert(“用双引号”)。