我在使用模式打開的HTML中使用視頻標記。目前它仍在播放,如果我退出模式而不暫停視頻。我還沒有JavaScript,因爲我添加的所有內容都不起作用。我也使用bootstrap。這裏是我的HTML:當模式關閉時停止播放視頻
<button type="button" data-toggle="modal" data-target="#myModal">
<h4>SHORT SLEEVED SHIRT<br><br>$20</h4>
<img src="images/femaleshortsleeved.jpg"> </button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<video class="video" width="960px" controls>
<source src="images/Short Sleeved Shirt.mp4" type="video/mp4">
</video>
<h2>Short Sleeved Shirt<br>$20</h2>
<h5>90s lightweight brown patterned shirt.<br>No marked size.<br>Will fit S to M.<br>Length: 62cm<br>Width: 56cm</h5>
<button type="button" class="btn btn-primary btn-lg">BUY NOW</button>
</div>
</div>
</div>
您是否嘗試過使用模式關閉的.pause()函數? – Theunis