2016-11-07 86 views
1

我正在使用底部有4或5個視頻的着陸頁上,每個視頻縮略圖上都有一個播放按鈕圖標。每個視頻都通過JavaScript加載,每個視頻都是h5文本。當您單擊任何視頻的播放按鈕時,它會將視頻移動到主視頻部分(視頻點1) - 並將視頻點1中的視頻和文本移動到剛剛單擊的視頻點。我有視頻切換,但我很難抓住h5的文本。下面是我目前有在HTML單擊播放按鈕時從元素獲取文本

<div class="row video-section-main-row""> 
       <div class="col-xs-12 main-vid-col"> 
        <div id="player" class="hidden"></div> 
        <a href="#/" class="play-icon-main" id="play-button-1"><img src="images/play-icon-largest.png"></a> 
        <img class="main-video vid-spot" id="video-spot-1" src=""> 
        <h5 class="main-video-headline" id="video-headline"></h5> 
       </div> 
      </div> 
      <div class="row video-section-thumbnail-row"> 
       <div class="col-xs-3 video-col"> 
        <img id="video-spot-2" src=""> 
        <a href="#/" class="play-icon" id="play-button-2"><img src="images/play-icon-largest.png"></a> 
        <h5 id="video-thumbnail-headline-1"></h5> 
       </div> 
       <div class="col-xs-3 video-col"> 
        <img id="video-spot-3" src=""> 
        <a href="#/" class="play-icon" id="play-button-3"><img src="images/play-icon-largest.png"></a> 
        <h5 id="video-thumbnail-headline-2"></h5> 
       </div> 
       <div class="col-xs-3 video-col"> 
        <img id="video-spot-4" src=""> 
        <a href="#/" class="play-icon" id="play-button-4"><img src="images/play-icon-largest.png"></a> 
        <h5 id="video-thumbnail-headline-3"></h5> 
       </div> 
       <div class="col-xs-3 video-col"> 
        <img id="video-spot-5" src=""> 
        <a href="#/" class="play-icon" id="play-button-5"><img src="images/play-icon-largest.png"></a> 
        <h5 id="video-thumbnail-headline-4"></h5> 
       </div> 
      </div> 
+2

有一個在H5沒有文字,你想要的ID? – Derek

+0

@Derek當頁面加載時,h5中的文本通過js加載。我將每個標題保存爲我的js中的變量。因此,當用戶能夠點擊播放按鈕時,h5 –

回答

1

在播放按鈕放單擊處理:

var videoText = $(this).siblings('h5').text(); 
+0

中會有文字完美顯示,謝謝! –