doter1995 2018-08-29 12:01
浏览 113

将src属性传递给循环中的iframe

i am passing source attribute to iframe from source Array that is consisting URL of different videos. but the problem is iframe take only first index of source array in each alteration of loop. Code is given below.

<script language="javascript" type="text/javascript">
$(function(){
    $('.close').click(function(){      
        $('iframe#myVideo1aV').attr('src', $('iframe#myVideo1aV').attr('src'));

    });
});
</script>

    <?php     $src=array("http://player.vimeo.com/video/182048025","http://www.youtube.com/embed/L7ZQ0o1Gp5Y","http://player.vimeo.com/video/182048025");

        $sq = "Select * from videos_topics;
        $result = $con->query($sq);
        while ($row = $result->fetch_assoc()) {?>
        <div class="input-group">

        <button class="" data-toggle="modal" data-target="#Modal" ><?php 
         echo $row['video'] ;?></button>
        </div>

        <div class="modal"  id="Modal" role="dialog">
           <div class="modal-dialog modal-dialog-centered" role="document">
             <div class="modal-content" style="background-color:black">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                    <div class="modal-body">
                        <iframe id="myVideo1aV" width="100%" height="400" <?php echo 'src="'.$src[$i].'" ';?>frameborder="0" allowfullscreen></iframe>
                    </div>

            </div>
        </div>
    </div>
    <?php  
     $i++;
    }?>
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料