0
我試圖用jquery按下特定按鈕時將某些視頻靜音。jquery在div中選擇視頻並將它們靜音
我有這樣的HTML代碼
<button id="mute">Mute all</button>
<button id="unmute">Unmute all</button>
<div id="displayer"></div>
的事情是,在某些時候,我的顯示器會充滿這樣的:
<div id="displayer">
<div id="row0" class="row">
<div class="col-md-2">
<video id="recorded0" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded1" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded2" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded3" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded4" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded5" autoplay="" loop="" src="some_video" controls=""></video>
</div>
</div>
<div id="row1" class="row">
<div class="col-md-2">
<video id="recorded6" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded7" autoplay="" loop="" src="some_video" controls=""></video>
</div>
<div class="col-md-2">
<video id="recorded8" autoplay="" loop="" src="some_video" controls=""></video>
</div>
</div>
</div>
這裏是我的javascript代碼:
$("#mute").click(function() {
$("#displayer > video").prop('muted', true);
});
$("#unmute").click(function() {
$("#displayer > video").prop('muted', false);
});
,它不起作用。我不明白爲什麼。有人能幫我嗎 ?
,而不是'$( 「#顯示器>視頻」)''試$( 「#顯示器的視頻」)' –
您是否嘗試過尋找了CSS選擇器? – gcampbell
@KartikeyaKhosla的偉大工程,謝謝。 – Devz