javascript - nodejs cheerio在每个循环中选择子元素

标签 javascript jquery node.js cheerio

我正在尝试选择 .info 类中的 strong a 标签

$(".info").each(function(i, item){
    console.log($(this).children("strong a").text())
});

它正确地选择了信息类,而不是 strong a

enter image description here

最佳答案

你应该可以做到

$(".info").each(function(i, item){
    console.log($("strong a", item).text())
});

关于javascript - nodejs cheerio在每个循环中选择子元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48941266/

相关文章:

node.js - 出现错误 : Stream yields empty buffer when resizing images from S3 with local node service

javascript - 使用按钮单击淡入多行文本

javascript - 无法设置 Kendo DropDownList 选定值

php - ajax请求未定义

php - 检查 php 脚本运行状态

node.js - Node native 驱动程序导致查询内部查询失败

javascript - Node 需要用方括号传递 arg 的模块?这是一个错误吗?

javascript - 组合两个变量

javascript - 如何在文档加载后立即调整 div 的大小

javascript - 同源策略 : Writes Allowed?