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();
});
精彩评论