请问点击按钮(往右移动300px)让盒子右移300px在JS里应该怎么写!代码:<!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> <style> *{ margin: 0; padding: 0; } #box{ width: 400px; height: 400px; border: 1px solid red; } #div1{ width: 200px; height: 200px; background-color: #37A3EB; margin-left:0; } </style></head><body><div id="box"><div id="div1"></div></div><input type="button" value="往右移动300px" id="it6" /><script>window.onload=function(){ var div1=document.getElementById("div1"); var it6=document.getElementById("it6"); it6.onclick=function(){ div1.style.margin="margin-left:300px" }}</script></body></html>
添加回答
举报
0/150
提交
取消