gpt4 book ai didi

javascript - jQuery 查询.children

转载 作者:行者123 更新时间:2023-12-02 16:48:25 25 4
gpt4 key购买 nike

$('.Name').children(function() {
var username = $('.Name').text();
console.log(username);
});

我很好奇如何让它抓取所有带有“title”标签的子项,并通过 console.log 逐一记录每个子项的值。

最佳答案

$('.Name > title').each(function() {
var username = $(this).text();
console.log(username);
});

这将获取所有标题元素,这些元素是具有类 Name 的所有元素的直接子元素,并为每个元素运行一个函数,将标题文本记录到控制台。

正在工作fiddle

关于javascript - jQuery 查询.children,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26910625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com