2014-09-26 3 views
0

문제가 있습니다. 클릭 한 비디오를 보여주는 비디오 iframe 팝업을 만들려고합니다.다른 div에서 src로 href 연결하기

이것은 동영상이있는 div입니다.

<iframe width="854" height="480" src="MYVIDEOLINKHERE" frameborder="0" allowfullscreen></iframe> 

은 내가 알아 내기 위해 노력하는 것은 내가 iframe이의 SRC에 클래스 "testtest"에서 href를 말할 수있는 방법입니다 :

<ul class="video_list"> 
     <?php 
     $result_video = mysqli_query($con,"SELECT * FROM guestlist_tvs ORDER BY created DESC LIMIT 16"); 
     while($row = mysqli_fetch_array($result_video)) { 
     ?> 
     <li rel='<?php echo $row['video_music_cat'];?>' cat='<?php echo $row['video_cat'];?>'> 
     <div class="testtest"> 
      <a href='http://www.youtube.com/embed/<?php echo $row['youtube_id']; ?>?rel=0&amp;wmode=transparent' class='video_thumb'> 
      <div class="video_img_wrapper"><img class='video_img'src="http://img.youtube.com/vi/<?php echo $row['youtube_id']; ?>/maxresdefault.jpg" width='240px' height='160px'> 
      <img class="play_button" src="images/play_button.png" alt="play" /></img></div> 
      <h3><?php echo $row['title']; ?></h3> 
      </a> 
     </div> 
     </li> 
     <?php 
     } 
     mysqli_close($con); 
     ?> 
     </ul> 

iframe이 팝업이 코드가 있습니다. 사전에

감사

+1

은 당신이해야한다고 생각 그것을위한 jQuery. –

+0

예를 들어 주시겠습니까? – ThomasV

+0

대화 상자를 만들 때 사용한 API는 무엇입니까? –

답변

0

내 솔루션 이벤트를 jQuery를 사용하여 클릭합니다

$(document).ready(function() { 
    $('.video_thumb').click(function() { 
     alert(this.getAttribute("src")); 
    }); 

}); 

JSFIDDLE DEMO

0

를 사용하여 해당 페이지에 스크립트 태그에서이 JQuery와

$(document).ready(function(){ 

    $(".play_button").click(function(){ 
    $("iframe").attr("src") =$(this).closest(".testtest").find("a").first().attr("href"); 




    }); 





}); 
관련 문제