<html>
<head>
<title> New Document </title> <script language="javascript" type="text/javascript">
var l=0;
var t=0;
var n=0;
function aa()
{
var thenew= document.createElement('div');
thenew.innerHTML = document.getElementById('lizi').innerHTML;
thenew.style.position="absolute";
l+=150;
t+=150;
n++;
thenew.style.left=l+"px";
thenew.style.top=t+"px";
thenew.style.border="solid 1px red";
thenew.style.background="silver";
thenew.style.width="200px";
thenew.style.height="100px";
thenew.id="div"+n;
thenew.setAttribute("onmousedown","down()");
thenew.setAttribute("onmousemove","move(this.id)");
thenew.setAttribute("onmouseup","up(this.id)");
thenew.setAttribute("onclick","fun(this.id)");document.getElementById('bbbb').appendChild(thenew);
//alert(document.getElementById('bbbb').innerHTML);
}
function bb()
{
document.getElementById('bbbb').childNodes[0].removeNode(true);
}
</script> </head> <body>
<form action="" method="post">
<div id="lizi"> remove <br />Frist Name: <input type="text" value="aaaa" name="name[]"/> </div>
<div id="bbbb" style="background-color:#CCCCCC;"> </div>
<a onclick="aa()" href="#" >Add new </a>
<a onclick="bb()" href="#" >dell </a>
</form> <script language="javascript" type="text/javascript">
var isdown = false
var beginx,beginy
function down() {
isdown = true;
} function move(obj) {
if (isdown){
alert(obj);
var endx = event.clientX;
var endy = event.clientY;
div1.style.left = parseInt( div1.style.left ) + endx-beginx;
div1.style.top = parseInt( div1.style.top ) + endy-beginy;
}
beginx = event.clientX;
beginy = event.clientY;
} function up(obj) {
isdown = false;
}document.body.onmousemove = move
document.body.onmouseup = up
</script>
</body>
</html>
DOWN()的方法没有执行 什么原因呀
<!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>
<title> New Document </title>
<script language="javascript" type="text/javascript">
var isdown=false;
var beginx,beginy;
function down() {
isdown=true;
} function move(obj) {
if (isdown){
//alert(obj);
obj.setCapture();
var endx = event.clientX;
var endy = event.clientY;
div1.style.left = parseInt( div1.style.left ) + endx-beginx;
div1.style.top = parseInt( div1.style.top ) + endy-beginy;
}
beginx = event.clientX;
beginy = event.clientY;
} function up(obj) {
isdown = false;
obj.releaseCapture();
} //document.body.onmousemove=move
//document.body.onmouseup=up
</script>
<script language="javascript" type="text/javascript">
var l=0;
var t=0;
var n=0;
function aa(){
var thenew= document.createElement('div');
thenew.innerHTML = document.getElementById('lizi').innerHTML;
thenew.style.position="absolute";
l+=150;
t+=150;
n++;
thenew.style.left=l+"px";
thenew.style.top=t+"px";
thenew.style.border="solid 1px red";
thenew.style.background="silver";
thenew.style.width="200px";
thenew.style.height="100px";
thenew.id="div"+n;
thenew.setAttribute("onmousedown","down()");
thenew.setAttribute("onmousemove","move(this)");
thenew.setAttribute("onmouseup","up(this)");
thenew.setAttribute("onclick","fun(this)"); document.getElementById('bbbb').appendChild(thenew);
//alert(document.getElementById('bbbb').innerHTML);
}
function bb(){
if(document.getElementById('bbbb').childNodes.length>0){
document.getElementById('bbbb').childNodes[0].removeNode(true);
}
}
function fun(obj){
//alert(obj);
}
</script> </head> <body>
<form action="" method="post" id="form1">
<div id="lizi"> remove Frist Name:<input type="text" value="aaaa" name="name[]"/></div>
<div id="bbbb" style="background-color:#CCCCCC;"></div>
<a onclick="aa()" href="#" >Add new</a>
<a onclick="bb()" href="#" >dell</a>
</form> </body>
</html>