javascript - java脚本中的querySelectorAll()返回零
问题描述
我使用 JS 在 html 页面中添加了元素,然后我使用查询 Selector All("element . class name") 来访问该元素,但它返回零。但是,我的网页中显示的元素。
var listItems=document.querySelectorAll(".list-items");
var x=listItems[0].querySelectorAll("img.list-item-img").length;
console.log(x);
<div class="list-items" id="mostReleaseList">
<!-- her will be tags by JS -->
</div>
解决方案
推荐阅读
- azure-cosmosdb - Azure Cosmos DB 和 Azure 空间锚点有什么区别?
- javascript - 从“4.2.0”升级到“5.7.0”后 Dropzone 停止工作(使用 jquery“3.3.1”)
- dynamics-crm - Tibco Scribe 中的 Dynamics CRM 元数据未刷新
- javascript - 将新的用户数据添加到 div
- c# - 从返回具有某些属性的相同对象的 API 反序列化 JSON
- sql - 如何验证日期的格式为 YYYYMMDD
- python - 有没有更好的方法以更短的行抓取 MSFT 数据?我已经尝试过了,但得到的问题是“模块”对象不可调用
- python-3.x - 单击按钮时的Python PyQt5终端命令执行问题
- postgresql - postgreSQL & PL/pgSQL:varchar(36) 的值太长,但我昨天将字段扩大到 60
- android - RecyclerView 中的 NullPointerException