Can somebody pls help me?
I'm currently working on a dynamic website. I have 2 navigations points and I have a video window on the right side. By clicking on one navigation point the respective video should appear in the video window. The problem is: my navigation list will be created dynamically and the video appearance as well (in this case the urls videos will be embedded from Youtube). Here is my PHP code where the list of navigation points will be created dynamically:
function reborn_videos($attribute){
ob_start();
$urls = $attribute['filme'];
$urls = explode(',', $urls);
?>
<div id="mobil_content">
<?php for($i=1; $i<= count($urls); $i++) {
$movie_title = $attribute['title'.$i];
?>
<div class="box">
<div class="box_title_video"><a class="expand"><?php echo $movie_title; ?> </a></div>
<?php foreach ($urls as $url) { ?>
<div class="box_body_iframe">
<iframe width="100%" height="315" src="https://www.youtube.com/embed/<?php echo trim($url); ?>" frameborder="0" allowfullscreen></iframe>
</div>
<?php } ?>
</div>
<?php } ?>
here is what i changed and looks right now:
function reborn_videos($attribute){
ob_start();
$urls = $attribute['filme'];
$urls = explode(',', $urls);
?>
<div id="mobil_content">
<?php for($i=1; $i<= count($urls); $i++) {
$movie_title = $attribute['title'.$i];
?>
<div class="box">
<div class="box_title_video"><a class="expand"><?php echo $movie_title; ?></a></div>
<div class="box_body_iframe">
<iframe width="100%" height="315" src="https://www.youtube.com/embed/<?php echo trim($urls[$i]); ?>" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<?php } ?>
and here the JQuery that I want to use to show and hide my videos:
var $alleVideos = $(".box_body_iframe");
function showVideos() {
$alleVideos.each(function(){
if ( $(this).hasClass('active') ) {
$(this).show();
} else{
$(this).hide();
}
});
}
$alleVideos.hide();
$(".box_title_video").click(function(){
$alleVideos.removeClass('active');
$(this).next().addClass('active');
showVideos();
});
in JQuery code i have no changes this is how the Browser output the html code:
<div id="mobil_content">
<div class="box">
<div class="box_title_video">
<a class="expand">reborn</a>
</div>
<div class="box_body_iframe" style="display: none;">
<iframe height="315" frameborder="0" width="100%" allowfullscreen="" src="https://www.youtube.com/embed/7PnRkyu0HTs">
</div>
</div>
<div class="box">
<div class="box_title_video">
<a class="expand">trailer</a>
</div>
<div class="box_body_iframe active" style="display: block;">
<iframe height="315" frameborder="0" width="100%" allowfullscreen="" src="https://www.youtube.com/embed/">
</div>
</div>
</div>
The problem is: the JQuery animation just shows one and always the same video in the video window. :-(
var $alleVideos = $(".box_body_iframe").hide(); $(".box_title_video").on('click', function() { $alleVideos.hide().filter($(this).next()).show(); });There seems to be no point in adding removingactive.