<html>
<head>
<title></title>
<script language=javascript>
function test(num){
var objdiv;
var rectsText={ "Rects":
[
{ "Left": 11, "Right":13, "Width": 100 , "Height": 100},
{ "Left": 200, "Right":200, "Width": 100 , "Height": 100}
]
}
objdiv=document.createElement("DIV");
var objname="divName";
objdiv.style.background='#FFFF00';
objdiv.style.visibility='visible';
objdiv.style.left=rectsText.Rects[0].Left;
objdiv.style.right=rectsText.Rects[0].Right;
objdiv.style.width=rectsText.Rects[0].Width;
objdiv.style.height=rectsText.Rects[0].Height;
objdiv.style.border = "5 groove black";
document.body.appendChild(objdiv);
}
function f(){
//调用test()里的div对象,当第二次点击按钮的时候 移动div
///求高手帮忙把代码写完
}
</script>
</head><body>
<input type="button" value="按钮" onclick="f()">
</body></html>
<head>
<title></title>
<script language=javascript>
function test(num){
var objdiv;
var rectsText={ "Rects":
[
{ "Left": 11, "Right":13, "Width": 100 , "Height": 100},
{ "Left": 200, "Right":200, "Width": 100 , "Height": 100}
]
}
objdiv=document.createElement("DIV");
var objname="divName";
objdiv.style.background='#FFFF00';
objdiv.style.visibility='visible';
objdiv.style.left=rectsText.Rects[0].Left;
objdiv.style.right=rectsText.Rects[0].Right;
objdiv.style.width=rectsText.Rects[0].Width;
objdiv.style.height=rectsText.Rects[0].Height;
objdiv.style.border = "5 groove black";
document.body.appendChild(objdiv);
}
function f(){
//调用test()里的div对象,当第二次点击按钮的时候 移动div
///求高手帮忙把代码写完
}
</script>
</head><body>
<input type="button" value="按钮" onclick="f()">
</body></html>
中通过document.getElementById("aaa");来获得div对象,然后对它进行移动。