开发者

Jquery - apply method to all elements returned

this is probably pretty straightforward开发者_运维百科 but i'm struggling with it - I want to pause all videos I have running in a div container. At the moment, this is what I have:

// Doesn't work
$("#vid").find("video").get().pause();
// Works
$("#vid").find("video").get(0).pause();

What's the best way to apply the pause function to each video element? A for/each loop?


$('video','#vid').each(function(){
     this.pause(); //find all videos in #vid and pause them
});


$('#vid').find('video').each(function(){
     $(this).pause();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜