我试图通过显示的按钮文本来识别按钮。在 firefox 开发人员中,我在 innerHTML 属性中看到了关联的文本 - 但我无法访问它 - 它是空的。
$("#objbefDlg .dlg-buttons .dlg-button").each(function() {
console.log("this ", this, " this.disabled ", this.disabled, " this.innerHTML ", this.innerHTML, " this.className ", this.className, " this.contentEditable ", this.contentEditable);
});
html代码:
<div id="objbefDlg" class="dialog">
<div class="dlg-main">
<div id="objdlg-cont-left">
...
</div>
<div id="objdlg-cont-right">
...
</div>
</div>
<div class="dlg-buttons">
<button class="dlg-button"></button>
<button class="dlg-button"></button>
<button class="dlg-button"></button>
<button class="dlg-button"></button>
</div>
</div>
另一方面,我可以毫无问题地访问其他属性。有没有人有提示我还能尝试什么? 我不能分享整个代码,但这里有一些摘录(在程序的其他地方它完全没有问题)。 非常感谢您的帮助 拉维尼亚
编辑:好像不允许我上传图片,所以我会尝试描述输出...... 开发者工具控制台输出:
"this " <button class="dlg-button"> " this.disabled " false " this.innerHTML " "" " this.className " "dlg-button" " this.contentEditable " "inherit"
"this " <button class="dlg-button"> " this.disabled " false " this.innerHTML " "" " this.className " "dlg-button" " this.contentEditable " "inherit"
"this " <button class="dlg-button" disabled=""> " this.disabled " true " this.innerHTML " "" " this.className " "dlg-button" " this.contentEditable " "inherit"
"this " <button class="dlg-button" disabled=""> " this.disabled " true " this.innerHTML " "" " this.className " "dlg-button" " this.contentEditable " "inherit"
开发者工具属性:
....
类名:“dlg-button”
....
contentEditable:“继承”
...
禁用:假
...
innerHTML:“Interrompre”
在这里我看到 innerHTML 中的文本,但我无法阅读它。
不幸的是,我经常不明白通过 javaScript 和/或 JQuery 访问元素是如何工作或不工作的。我不清楚为什么在这种情况下我无法访问 innerHTML。我希望你能帮助我为黑暗带来光明......