作者yaca (最近心情有点怪)
看板Web_Design
标题[问题] javascript动态生成button
时间Sat Jan 20 03:41:52 2007
我利用生成子节点的观念去做
但button 我还是不会做,指点一下吧
我附上我的程式码
------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>下拉式选单节点</title>
<style>
.menutitle {
font-family:新细明体;font-size:20;width:100;
height:14;
background-color:#88FFFF;
position:absolute;top:150;
}
.menu {border:groove 3px;
font-family:新细明体;font-size:18;width:240;
height:14;
background-color:#44eeee;
position:absolute;
top:150;
visibility:hidden;
}
</style>
</head>
<body onmouseover="hidemenu();" bgcolor="#BBFFFF">
<p><font color="#0000FF" size="5" face="全真综艺体">下拉式选单的节点
</font></p>
<p>子节点内容:<input type="text" id=t1 size="20" ></p>
<input type="button" size="12" value="新增子节点" onclick="append_node();">
<hr>
<span id=mt1 class="menutitle" style="left:10;z-index:2"
onmouseover="showmenu();">
test<br>
</span>
<span id=m1 class="menu" style="left:10;z-index:3" onmouseover="showmenu();">
test<br>
<FORM >
<INPUT TYPE="button" value='Sports' ><br>
<INPUT TYPE="button" value='Heath' ><br>
<INPUT TYPE="button" value='Finance' ><br>
</span></FORM>
<script language="javascript">
//新增子节点的函数
function append_node(){
var tnode1,tnode2,tnodebr;
tnode1=document.createElement('INPUT TYPE=button');
tnodebr=document.createElement("br");
m1.appendChild(tnode1);
m1.appendChild(tnodebr);
var textnodex=document.createTextNode(t1.value);
tnode2=tnode1.appendChild(textnodex ); <---------我想应该是这里要修改
我直接做,得到是断行
}
function hidemenu(){
m1.style.visibility="hidden";
}
function showmenu(){
m1.style.visibility="visible";
event.cancelBubble=true;
}
</script>
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.195.65.53