我有一个单页应用程序,它的页面由 <section>
分隔元素。内容正在从后端动态输出。我将如何使用 jQuery 遍历应用程序并查看包含 $('.narration_audio')
的 div 元素的部分的数据索引.
基本上,我想要完成的是当用户访问包含该 div 元素的页面(部分)时,在标题中显示音频播放器。否则会使音频播放器变灰。
最佳答案
试试这个:
$("section").each(function() {
var this_el = $(this);
if (this_el.find('.narration_audio').length) {
var the_data_index = this_el.data('index');
}
}
关于javascript - 查找包含特定 div 的部分元素的数据索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23917821/