如何在 IE 中的 HTML 中设置输入标记的内部值
我正在尝试在 IE 中动态设置值标签的innerHTML。
我期望的输出是这样的。
<input type="hidden" >a0FQ0000009rJfCMAU</input>
我在 IE 中尝试了innerHTML,但它不起作用,因为它支持 INPUT 元素。于是,我在绝望中尝试了以下方法。
myElementId.setAttribute("value",textNodeId);
不幸的是这不是我想要的。
<input type="hidden" value="a0FQ0000009rJfCMAU">
请指教。
I am trying to set dynamically innerHTML for value tag in IE.
The output I expect is this.
<input type="hidden" >a0FQ0000009rJfCMAU</input>
I tried innerHTML in IE but it was not working since it is supported for INPUT element. So, I tried the following out of desperation.
myElementId.setAttribute("value",textNodeId);
Unfortunately this is not what I want.
<input type="hidden" value="a0FQ0000009rJfCMAU">
Please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您检查
input
元素的规范,您会发现其内容模型 应为空。因此,您尝试查找的是逻辑上无效的 HTML。请参阅此处。
If you check the
input
element's specification, you see that its Content Model should be empty. Thus, what you try to find is logically invalid HTML.See here.
如果你想动态更改或设置输入标签的值,你必须首先定义它的名称或id,然后在javascript中你可以设置它,就像
我希望这对你有帮助。
If you want to change or set the value of input tag dynamically, you have to first define its name or id and then in javascript you can set it like
I hope this helps you.