2013-08-04 5 views
0

제목과 같이 img-tag를 video-tag로 변경하고 싶습니다. 슬라이드 쇼를 만들고 ArrayList 끝에 비디오가 있습니다. 그러나 html 코드에서 이미지를 표시하기 위해 img 태그를 사용했습니다. 이제 Array-List가 비디오에 오면 img를 비디오로 변경하고 싶습니다.img-tag to video-tag to javacript

HTML 코드 :

<div id="content1" class="section"> 
     <div class="menucont" > 
         Commercial Shoot for FILA, Lookbook SS2014</br> 
         Styled by Stephen Mann.</br> 
         Assisted by PYO KHANG.</br> 
         Models: Katja, ELITE MODELS</br> 
     <div id="zahl1"> 1/20 </div> 
     <div class="pfeil" onClick="zurueck1();"> < </div> 
     <div class="pfeil" onClick="weiter1();"> > </div> 
    </div> 


    <div class="wraptocenter"><span></span><img src="../img/2lucy/serie/lucy_bytimothyschaumburg01.jpg" id="imgcont1" class="imgcontstyle" onClick="weiter1();"> 
    </div> 
</div> 

JS-코드 : 사전에

pic1 = new Array(); 
pic1[1] = new Image(); pic1[1].src = "../img/2lucy/serie/lucy_bytimothyschaumburg01.jpg"; 
pic1[2] = new Image(); pic1[2].src = "../img/2lucy/serie/lucy_bytimothyschaumburg02.jpg"; 
pic1[3] = new Image(); pic1[3].src = "../img/2lucy/serie/lucy_bytimothyschaumburg03.jpg"; 
pic1[4] = new Image(); pic1[4].src = "../img/2lucy/serie/lucy_bytimothyschaumburg04.jpg"; 
pic1[5] = new Image(); pic1[5].src = "../img/2lucy/serie/lucy_bytimothyschaumburg05.jpg"; 
pic1[6] = new Image(); pic1[6].src = "../img/2lucy/serie/lucy_bytimothyschaumburg06.jpg"; 
pic1[7] = new Image(); pic1[7].src = "../img/2lucy/serie/lucy_bytimothyschaumburg07.jpg"; 
pic1[8] = new Image(); pic1[8].src = "../img/2lucy/serie/lucy_bytimothyschaumburg08.jpg"; 
pic1[9] = new Image(); pic1[9].src = "../img/2lucy/serie/lucy_bytimothyschaumburg09.jpg"; 
pic1[10] = new Image(); pic1[10].src = "../img/2lucy/serie/lucy_bytimothyschaumburg10.jpg"; 
pic1[11] = new Image(); pic1[11].src = "../img/2lucy/serie/lucy_bytimothyschaumburg11.jpg"; 
pic1[12] = new Image(); pic1[12].src = "../img/2lucy/serie/lucy_bytimothyschaumburg12.jpg"; 
pic1[13] = new Image(); pic1[13].src = "../img/2lucy/serie/lucy_bytimothyschaumburg13.jpg"; 
pic1[14] = new Image(); pic1[14].src = "../img/2lucy/serie/lucy_bytimothyschaumburg14.jpg"; 
pic1[15] = new Image(); pic1[15].src = "../img/2lucy/serie/lucy_bytimothyschaumburg15.jpg"; 
pic1[16] = new Image(); pic1[16].src = "../img/2lucy/serie/lucy_bytimothyschaumburg16.jpg"; 
pic1[17] = new Image(); pic1[17].src = "../img/2lucy/serie/lucy_bytimothyschaumburg17.jpg"; 
pic1[18] = new Image(); pic1[18].src = "../img/2lucy/serie/lucy_bytimothyschaumburg18.jpg"; 
pic1[19] = new Image(); pic1[19].src = "../img/2lucy/serie/lucy_bytimothyschaumburg19.jpg"; 
pic1[20] = new Image(); pic1[20].src = "../img/2lucy/video/lucy.mp4"; 

var b=1; 

function weiter1() 
{ 
    ++b; 
    if (b>20) b=1; 
    document.getElementById('imgcont1').src = pic1[b].src; 
    document.getElementById('zahl1').innerHTML = [b] + "/20"; 
} 

function zurueck1() 
{ 
--b; 
    if (b<1) b=20; 
    document.getElementById('imgcont1').src = pic1[b].src; 
    document.getElementById('zahl1').innerHTML = [b] + "/20"; 
} 

감사합니다,

최대

PS : 나는 아주 새로운 오전 자바 스크립트.

답변

0

비슷한 문제가 있으며 스레드 here이 나를 도와주었습니다. 간단히 말하자면 태그 유형을 변경할 수 없습니다. 그러나 너 수 있습니다 적절한 유형의 새로운 요소를 만들어, 바른 장소에 넣어하고 오래된 요소를 제거하십시오. 이전 요소의 자식 노드를 가져 와서 새 요소에 놓을 수도 있습니다.