$('.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/