Trying to update the attribute value for each video html tag (classname=".video_block video") by using their respective child div tag (classname="posterURL").
JQuery -
$(document(){
$('.video_block .posterURL').each(function() {
var poster = $(this).data("poster")
$(.video_block video).attr('poster', poster);
})
})
HTML -
<div class="container">
<div class="media_block">
<div class="video_block">
<video
controls
src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
width="620">
</video>
<div class="posterURL" data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"></div></div>
</div>
<div class="video_block">
<video
controls
src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
width="620">
</video>
<div class="posterURL" data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"></div></div>
</div>
<div class="video_block">
<video
controls
src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
width="620">
</video>
<div class="posterURL" data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"></div></div>
</div>
</div>
</div>
Please share your thoughts!
Thanks in advance!