為什么結(jié)果沒出來,都沒有反應(yīng)
<!DOCTYPE html>
<html>
<head>
?? ?<meta charset="UTF-8">
?? ?<title>JS動(dòng)畫2</title>
<style type="text/css">
*{margin: 0;
?padding: 0;
?}
#share{
?? ?width: 200px;
?? ?height: 200px;
?? ?background-color:#11FA45 ;
??? position: relative;
??? left: -200px;
}
#share span{
?? ?width: 60px;
?? ?height: 50px;
?? ?line-height: 50px;
?? ?background-color: #F36812;
?? ?position: absolute;
??? text-align: center;
??? top:100px;
??? right: -60px;
}
</style>
</head>
<body>
?? ?<div id="share">
??????? <span>分享</span>
??? </div>
<script type="text/javascript">
?? ?window.onload=function(){
?? ?var move=document.getElementById("share");
?? ?move.onmouseover=function(){
?? ??? ?startmove();
?? ?}
}
?var timer=null;
function startmove(){
?? ?clearInterval(timer);
?? ?var move=document.getElementById("share");
?? ?timer=setInterval(function(){
?? ??? ?if (move.offsetLeft>=0) {
?? ??? ? ?? ?clearInterval(timer);
?? ??? ? } else{
?? ??? ??? ?move.style.left=move.offsetLeft+10+'px';}
?? ??? ? },30)
?? ??? ?}
?? ??? ?
</body>
</script>
</html>
2015-12-16
</body>
</script>這塊寫錯(cuò)了,應(yīng)該是
</script>
</body>
2016-01-13
將</body>和</script>兩個(gè)標(biāo)簽互換就可以了
2016-01-13
<!DOCTYPE html>
<html>
<head>
??? <meta charset="UTF-8">
??? <title>JS動(dòng)畫2</title>
<style type="text/css">
*{margin: 0;
?padding: 0;
?}
#share{
??? width: 200px;
??? height: 200px;
??? background-color:#11FA45 ;
??? position: relative;
??? left: -200px;
}
#share span{
??? width: 60px;
??? height: 50px;
??? line-height: 50px;
??? background-color: #F36812;
??? position: absolute;
??? text-align: center;
??? top:100px;
??? right: -60px;
}
</style>
</head>
<body>
??? <div id="share">
??????? <span>分享</span>
??? </div>
<script type="text/javascript">
??? window.onload=function(){
??? var move=document.getElementById("share");
??? move.onmouseover=function(){
??????? startmove();
??? }
?? ?move.onmouseout=function(){
??????? startmout();
??? }
}
?var timer=null;
function startmove(){
??? clearInterval(timer);
??? var move=document.getElementById("share");
??? timer=setInterval(function(){
??????? if (move.offsetLeft>=0) {
???????????? clearInterval(timer);
???????? } else{
??????????? move.style.left=move.offsetLeft+10+'px';}
???????? },30)
??????? }
?</script>????? ?
</body>
</html>
2015-12-16
你的body的問題,把結(jié)束標(biāo)簽提出去