|
发表于 2020-9-27 19:30:01
|
显示全部楼层
你可以通过document对象来添加新东西,比如document.createElement
<SCRIPT>
function fnCreate(){
oData.innerHTML="";
var oOption=oSel.options[oSel.selectedIndex];
if(oOption.text.length>0){
var aElement=document.createElement(oOption.text);
eval("aElement." + oOption.value + "='" + oText.value + "'");
if(oOption.text=="A"){
aElement.href="javascript:alert('A link.')";
}
}
oData.appendChild(aElement);
}
</SCRIPT>
<SELECT ID="oSel" onchange="fnCreate()">
<OPTION VALUE="innerText">A
<OPTION VALUE="value"><INPUT TYPE="button">
</SELECT>
<INPUT TYPE="text" ID="oText" VALUE="Sample Text">
<SPAN ID="oData" ></SPAN> |
|