如何改变type属性

lljllj2000 2002-04-04 08:54:25
如何用button改变一个 type="hidden"的input为 type="button"?

<INPUT name="cancle" type="hidden" value="111">
<INPUT name="ok" onclick="ok_action()" type="button" value="確定">
...全文
97 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Reve 2002-04-04
  • 打赏
  • 举报
回复
cancle.outerHTML='<INPUT name="cancle" type="button" value="111">';
karma 2002-04-04
  • 打赏
  • 举报
回复
According to MSDN documentation:

As of Microsoft® Internet Explorer 5, the type property is read/write-once, but only when an input element is created with the createElement method and before it is added to the document.

weidegong 2002-04-04
  • 打赏
  • 举报
回复
Perhaps,you can use it in this way:

<form name=mxh1>
<input id=mxh style="visibility:hidden">
<input name=aa type=radio onclick="document.all.mxh.style.visibility='visible'">显示
<input name=aa type=radio onclick="document.all.mxh.style.visibility='hidden'">隐藏
</form>

<script>
for(var i=0;i<document.mxh1.elements.length;i++)
{
if(document.mxh1.elements[i].type=="radio")
document.mxh1.elements[i].checked=""
}
</script>
BrentIvan 2002-04-04
  • 打赏
  • 举报
回复
<script language="JavaScript">
function changeType() {
document.all.oDiv.innerHTML = "<input type=\"button\" name=\"oInput\" id=\"oInput\">";
}
</script>
<div name="oDiv" id="oDiv"><input type="hidden" name="oInput" id="oInput" value="1"></div>
<input type="button" value="click me" onclick="changeType()">
孟子E章 2002-04-04
  • 打赏
  • 举报
回复
不可以修改:
可以这样
<form>
<INPUT name="cancle" type="button" value="111" style="display:none">
<INPUT name="ok" onclick="cancle.style.display='block'" type="button" value="確定">
</form>

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧