咋回事,哪出问题啦,,让p的背景条自动增加长度。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<style type="text/css">
p{background-color:blue;
width:100px;]
</style>
</head>
<body>
<p id="f">我们都是好孩子</p> </body>
<script type="text/javascript">
var len=document.getElementById("f").style.width;
var lenn=parseInt(len);
alert(len);
function move( ){
lenn+=10;
len=lenn+"px";
}
setInterval("move( )",1000);
</script>
</html>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<style type="text/css">
p{background-color:blue;
width:100px;]
</style>
</head>
<body>
<p id="f">我们都是好孩子</p> </body>
<script type="text/javascript">
var len=document.getElementById("f").offsetWidth;function move(){
len +=10
document.getElementById("f").style.width=len+"px";
}
setInterval("move()",1000); </script>
</html>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<style type="text/css">
p{background-color:blue;
width:100px;]
</style>
</head>
<body>
<p id="f">我们都是好孩子</p> </body>
<script type="text/javascript">
var len=document.getElementById("f").style.width;
var lenn=parseInt(len) || 0;function move(){
lenn+=10;
len=lenn+"px";
document.getElementById("f").style.width = len;
}
setInterval("move()",1000); </script>
</html>