当我尝试获取 Bootstrap 生成的 DOM 元素时,它返回 null。
var x= document.getElementById(element.getAttribute('aria-describedby'));
x 返回空值。我正在尝试在 openlayers 中使用弹出窗口。为什么会这样?
最佳答案
如果没有找到具有该 ID 的元素,则 getElementById
方法将返回 null。请注意,该值区分大小写。因此,aria-descriptedby 的值需要与相应元素上的 ID 值具有相同的大小写。最后,确保此代码在所需元素(具有目标 id 值的元素)已添加到 DOM 之后运行。
关于javascript - 'aria-describedby'什么时候返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34237787/