<!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=gb2312" /> <title>无标题文档</title> </head> <body id="test"> <input id="add" type="button" value="增加" disabled="disabled" οnclick="add();"/> <input id="del" type="button" value="删除" οnclick="del();"/> <div id="target">被控制的目标元素</div> <script language="javascript"> var body = document.getElementById("test"); var target = document.getElementById("target"); function add() { body.appendChild(target); document.getElementById("add").disabled = "disabled"; document.getElementById("del").disabled = ""; } function del() { body.removeChild(target); document.getElementById("add").disabled = ""; document.getElementById("del").disabled = "disabled"; } </script> </body> </html>