问题标签 [innertext]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
272 浏览

c# - how to edit utf-16 xml file if it have string line after the end of the main Node

I have Special XML file with utf-16 encoding type. this file used to store data and I need to Edit it Using C# windows forms Application

the problem is: it is not ordinary XML file Because at the very End of the file I have a string line too, and that would give this error

when I try to load it as xml file

I tried to temporary replace the last line and get it back after I change the inner text, and it works But I lost the declaration Line and I didn't find a way to rewrite it when I have that text at the end of the file !_
so I need to change the InnerText of (Serie) and (No) nodes but I don't Want to lose the declaration Line or the string text at the end of the file

0 投票
1 回答
3253 浏览

java - 如何使用 webdriver 通过其内部文本查找元素

我试图通过它的内部文本来查找和选择一个元素。我的脚本导航到我需要选择指定电子邮件的收件箱。收件箱中的所有电子邮件都具有相同的 id 和类,它们的不同之处在于类的内部文本。

我尝试了以下和其他变体,但没有成功。

HTML:

0 投票
1 回答
314 浏览

c# - 使用相似的标签(元素)名称更新 xml innerText

我的问题是我的 xml 文件中有一个最多出现 3 次的电子邮件元素,如下所示:

当我尝试使用以下代码编辑 3 个标签时,

只编辑了第一封邮件,由于相同的xml元素名称存在覆盖问题。

我尝试xnl[0]["email"][0].InnerText = "D";选择第一个电子邮件元素名称,但这不起作用。有什么建议吗?

更新:(带代码)

c#代码:

xml代码:

0 投票
2 回答
3391 浏览

javascript - 如何判断一个 HTML 元素是否为空?

我想知道一个元素是否为空。可能这也是帮助人们理解innerText 和 innerHTML 之间区别的最佳示例之一。

以下是示例:

Example_Number | 内部HTML | 内文 | #childElements | isElementEmpty(结果)

1..........................| 非空......| 空…………| 0.......................| 是的

2..........................| 非空......| 空…………| 1.......................| 不

3..........................| 非空......| 不是空的..| 0.......................| 不

4..........................| 非空......| 不是空的..| 0.......................| 不

5..................| 空…………| 空…………| 0.......................| 是的

在#5 中,考虑了修整值。

显然,innerHTML 并不能检查元素是否为空。现在,我们需要检查 innerText/textContent 和 numberOfChildElement 的贡献。所以基于以上发现,我得出结论

当满足这两个条件时,元素为空。

  1. 修剪的 innerText/textContent 为空。(满足#5)
  2. 子元素的数量为零。(满足#2)

所以代码变成了

我只是想验证我的方法,并告诉我是否错过了这里的任何用例,或者更好的解决方案真的很有帮助。

0 投票
3 回答
2339 浏览

javascript - Javascript Document.write 不工作

我正在尝试基于 Innertext 动态填充 div。谁能告诉我为什么这不起作用?

0 投票
2 回答
3859 浏览

javascript - 无法设置未定义或空引用的属性“innerText”

我写了这段代码:

当我运行它时,得到了这个错误:无法设置未定义或空引用的属性'innerText'

0 投票
4 回答
17210 浏览

javascript - 如果 div innerText 发生变化,则触发 JavaScript 事件

我想在 div 的 innerText 更改时发出警报:

不起作用,请帮助。

0 投票
1 回答
230 浏览

javascript - 在 IE 和 Chrome 工作时,Firefox 剑道按钮文本没有改变

这是我的代码:

在复选框更改时正在更改innerText剑道按钮。这在 IE 和 Chrome 中运行良好,而在 Firefox 中则不起作用。

谁能告诉我确切的问题是什么?

0 投票
2 回答
220 浏览

javascript - Javascript innerText 细微差别

我想知道 innerText 属性。考虑以下标记:

HTML

然后,让我们运行以下代码:

JS

在这里提琴

按原样运行此代码,输出foo和空行,然后bar.

如果我注释掉脚本的第一行,然后取消注释第二行,然后在包含文本的 div 的确切级别上关闭,则此代码输出foo, found, bar

我的问题是:如果在第一次迭代中脚本输出foo,为什么a[i].innerText == "foo"不是true?哦,那条空行是从哪里来的?

0 投票
2 回答
4749 浏览

javascript - 如何在 JavaScript 中为 Chrome 设置 innerText?

我正在尝试在 Chrome 中的元素的开始和结束标记之间设置 innerText,但到目前为止它不起作用。这是为什么?我试过这些:

这是小提琴:http: //jsfiddle.net/La1tadpd/