簡體   English   中英

將img-tag更改為Javascript中的video-tag

[英]change img-tag to video-tag in Javascript

如標題所示,我想將img標簽更改為視頻標簽。 我正在制作幻燈片,在ArrayList的末尾有一個視頻。 但是在html代碼中,我使用了img標簽來顯示圖像。 現在,當數組列表出現在視頻中時,我想將img更改為視頻。

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:我是Java語言的新手。

我遇到了類似的問題, 這里的線程幫助了我。 長話短說,您無法更改標簽的類型。 但是,您可以創建適當類型的新元素,將其放在正確的位置,然后刪除舊元素。 您甚至可以將舊元素的子節點放到新元素中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM