javascript动态创建控件的最简洁方法:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <style type="text/css" >
a.god
{
  width:200px;
  height:30px;
  font-family:'宋体',Arial;
  font-size:14px;
  text-decoration:none;
  display:block;
  padding:10px,25px,5px,25px;
  color:#000;
}
a.god:hover
{
  color:#fff;
  background-color:#339;
}
  </style>
  <****** type="text/javascript" >
function AddingControls()
{
  var strHtml = "<a class='god' href='http://www.baidu.com' >XK-000-2010-02-06-01</a>";
  strHtml += "<a class='god' href='http://www.baidu.com' >XK-000-2010-02-06-01</a>";
  strHtml += "<a class='god' href='http://www.baidu.com' >XK-000-2010-02-06-01</a>";
  strHtml += "<a class='god' href='http://www.baidu.com' >XK-000-2010-02-06-01</a>";
  document.getElementById("panel1") = strHtml;
}
function doing()
{
  alert("god!");
  return false;
}
  </script>
</HEAD>

<BODY>
<div id="panel1" >
</div>
<input type="button" value="增加控件"   >
<input type="button" value="关闭" >
</BODY>
</HTML>

posted on 2010-03-18 17:16  冰危节奏  阅读(372)  评论(0编辑  收藏  举报

导航