javascript - 'aria-describedby'什么时候返回空值

标签 javascript html openlayers-3

当我尝试获取 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/

相关文章:

openlayers-3 - OpenLayers 3 中的动画 gif

javascript - pug(jade) 中的错误不显示布局中的内容

javascript - 在数据 spy "affix"内启用滚动

html - 没有内容高度设置问题的纯 css 垂直选项卡

javascript - Javascript 可以读取任何网页的源代码吗?

javascript - 在 Openlayers 3 中只允许一个绘图功能

javascript - 我们如何使用nodejs将多个blob上传到azure

javascript - 选择 GridView 中的所有复选框

html - 将鼠标悬停在不同 div 中的链接上时如何隐藏图像

openlayers-3 - 无法为矢量图层中单击的要素设置样式