gpt4 book ai didi

javascript - 嵌套 foreach jquery child

转载 作者:可可西里 更新时间:2023-11-01 14:44:01 25 4
gpt4 key购买 nike

<div class="right_channel_bar" id="channel_box" style="margin-left: -12px;">
<div class="row" id="channel_1">
<span class="program" data-start-time="00:00" data-end-time="00:30" style="margin-left: 0px">
<a class="truncate" style="width: 180px; href=" javascript:void(0); "=" ">bing technology network</a></span><span class="program " data-start-time="00:31 " data-end-time="01:00 " style="margin-left: 6px "><a class="truncate " style="width: 174px; href=" javascript:void(0);"="">songs</a>
</span>
<span class="program" data-start-time="01:02" data-end-time="02:00" style="margin-left: 12px">
<a class="truncate" style="width: 348px; href=" javascript:void(0); "=" ">news channel</a></span><span class="program " data-start-time="02:05 " data-end-time="03:00 " style="margin-left: 30px "><a class="truncate " style="width: 330px; href=" javascript:void(0);"="">evenst</a>
</span>
<span class="program" data-start-time="03:00" data-end-time="04:00" style="margin-left: 0px">
<a class="truncate" style="width: 360px; href=" javascript:void(0); "=" ">microsoft technology network</a></span><span class="program " data-start-time="04:00 " data-end-time="04:45 " style="margin-left: 0px "><a class="truncate " style="width: 270px; href=" javascript:void(0);"="">yahoo technology network</a>
</span>
</div>
<div class="row" id="channel_2">
<span class="program" data-start-time="00:00" data-end-time="00:30" style="margin-left: 0px">
<a class="truncate" style="width: 180px; href=" javascript:void(0); "=" ">bing technology network</a></span><span class="program " data-start-time="00:31 " data-end-time="01:00 " style="margin-left: 6px "><a class="truncate " style="width: 174px; href=" javascript:void(0);"="">songs</a>
</span>
<span class="program" data-start-time="01:02" data-end-time="02:00" style="margin-left: 12px">
<a class="truncate" style="width: 348px; href=" javascript:void(0); "=" ">news channel</a></span><span class="program " data-start-time="02:05 " data-end-time="03:00 " style="margin-left: 30px "><a class="truncate " style="width: 330px; href=" javascript:void(0);"="">evenst</a>
</span>
<span class="program" data-start-time="03:00" data-end-time="04:00" style="margin-left: 0px">
<a class="truncate" style="width: 360px; href=" javascript:void(0); "=" ">microsoft technology network</a></span><span class="program " data-start-time="04:00 " data-end-time="04:45 " style="margin-left: 0px "><a class="truncate " style="width: 270px; href=" javascript:void(0);"="">yahoo technology network</a>
</span>
</div>
</div>

从上面提到的 HTML 中,我需要获取 data-start-time 但我无法获取。请帮我修复下面的 jquery 代码:

$('#channel_box .row').each(function () {
$(this).children(".program").each(function () {
console.log($(this).data('start-time') + ' - ' + $(this).data('start-time'))
});
});

最佳答案

尝试一下:

console.log($(this).attr('data-start-time') + ' - ' + $(this).attr('data-start-time'))

关于javascript - 嵌套 foreach jquery child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33054567/

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