<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title></title>
<style type="text/css">
#d2
{
width: 100px;
color: yellow;
height: 100px;
border: 1px solid;
position: absolute;left: 0px; top: 0px;
background-color: #000000;
text-align: center;
font-size: 35px;
font-weight: bolder;
}
#d1
{
width: 100px;
height: 100px;
border: 1px solid;
margin-top: 100px;
margin-left: 50px;
}
</style>
<script type="text/javascript">
flag=true;
x=0
function fun1()
{
var input = document.getElementsByTagName("input")[0];
var div1=document.getElementsByTagName("div")[0];
if(x>=innerWidth-div1.offsetWidth)
{
flag=false;
}
else if(x<=0)
{
flag=true;
}
if(flag)
{
x=x+80
}
else
{
x=x-80
}
div1.style.left=x+"px"
}
</script>
</head>
<body>
<div id="d2">动次打次</div>
<div id="d1">
<input type="button" value="动起来!" onclick="fun1()"/>
</div>
</body>
</html>
jquery 点击左右箭头滑动图片, javascript点击按钮左右移动
转载文章标签 html css javascript 文章分类 jQuery 前端开发
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章