在脚本中添加元素 [英] Add elements in script
本文介绍了在脚本中添加元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我在这个网站上是新手。
我正在开发一个appi。我需要在运行时在< div>中添加文本框。
单击一下按钮,我调用以下函数(Javascript):
Hello Friends,
I am new on this site.
I am developing an appi. where I need to add textboxes at runtime in a <div>.
On one button click, I call the following function (Javascript):
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号
推荐答案
据我所知你不能像你那样使用createElement ...元素是一个dom节点...创建它首先。如果需要设置属性,则必须使用setAttribute-method。你可以设置innerText,innerHTML或创建一个额外的textNode来附加该元素的文本......例如下面:
as far as i know you cannot use createElement the way you did ... an element is a dom node ... create it first. if you need to set Attributes then you have to use the setAttribute-method. and you may set innerText, innerHTML or create an additional textNode to append text for that element ... example below:
展开 | 选择 | 换行 | 行号
IE = Internet Explorer
FF = Firefox,Opera,Netscape
Dom在IE中的工作方式与在FF或IE中查看的FF不同吗?如果你需要帮助使它跨浏览器兼容回复。
IE=Internet Explorer
FF=Firefox, Opera, Netscape
Dom works differently in IE than it does FF are you viewing this in FF or IE? also if you need help making it cross-browser compatible reply back.
到现在为止,我设法显示元素。但事件似乎没有被注册,即点击按钮,没有任何反应。他们也没有错误信息,
更新的代码是:
Hi,
By now, I somehow managed to dispaly the elements. But the events seems ot to be registered i.e. On click of button, nothing happens. Their is no error msg also,
Updated Code is :
展开 | 选择 | Wrap | 行号
这篇关于在脚本中添加元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文