【发布时间】:2018-02-08 07:33:40
【问题描述】:
我刚刚尝试在我的视频上添加文字。视频悬停时自动启动。上面的文本悬停是“禁用”的。是否有任何选项可以在不影响悬停的情况下显示文本?文字是绝对的。
我使用 js 启动视频。文本位于顶部的 div 中。
window.onload = function() { //executes this code after the DOM loads
//--- this is the selector element. Feel free to change this if you don't want all video objects targeted.
const vids = document.getElementsByTagName(`video`)
//--- Now we loop over all of the selected elements and add event listeners
for (let i = 0; i < vids.length; i++) {
vids[i].addEventListener( `mouseover`, function(e) {
vids[i].play()
})
vids[i].addEventListener( `mouseout`, function(e) {
vids[i].pause()
})
}
}
【问题讨论】:
-
欢迎来到 StackOverflow!为了让我们更好地帮助您,您能否更新您的问题,以便在minimal, complete, and verifiable example 中显示您的相关代码。有关更多信息,请参阅有关how to ask good questions 的帮助文章,并使用tour of the site :) 您可能需要修改您的
onhover功能以包括文本的悬停,但我们不知道没有看到你的代码。