Vote count: 0
I am using .wrap to wrap all video embeds in a responsive container.
var $iframeVideo = $('iframe[src*="youtube.com/embed"], iframe[src*="player.vimeo"]');
$iframeVideo.each(function () {
// Add wrapper to make video responsive
$(this).wrap('<div class="video-wrapper"></div>');
});
The problem is that sometimes the video may have a sibling caption div which also needs to be wrapped. Sometimes it may not. In the future there may be other elements with different classes. How can I wrap all siblings of the video with the video wrapper class?
<iframe type="text/html"
src="http://www.youtube.com/embed/?rel=0&controls=0&showinfo=0&autoplay="
frameborder="0">
</iframe>
<div class="sibling"></div>
<p class="another sibling"></p>
asked 36 secs ago
How can I .wrap an element and all of it's unknown siblings
Aucun commentaire:
Enregistrer un commentaire