js控制div上移或下移
发布网友
发布时间:2022-04-07 05:41
我来回答
共1个回答
热心网友
时间:2022-04-07 07:10
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body style="height:1300px;">
<input name="" type="button" value="上" onclick="document.getElementById('MyDiv').style.top=parseInt(document.getElementById('MyDiv').style.top)-5" />
<input name="" type="button" value="下" onclick="document.getElementById('MyDiv').style.top=parseInt(document.getElementById('MyDiv').style.top)+5"/>
<input name="" type="button" value="左" onclick="document.getElementById('MyDiv').style.left=parseInt(document.getElementById('MyDiv').style.left)-5"/>
<input name="" type="button" value="右" onclick="document.getElementById('MyDiv').style.left=parseInt(document.getElementById('MyDiv').style.left)+5"/>
<div id="MyDiv" style="top:300px;left:300px; width:50px; height:50px; background-color:red; position:absolute;">Move</div>
</body>
</html>
给你代码,有不懂的可以再问。追问你QQ是多少?帮我看看这代码怎么加上上移和下移的功能 我QQ是370946641