我在一个网站上有一个HTML5视频,但是我不喜欢仅仅坐在海报图片上的控件的外观,所以我添加了这个jQuery来在悬停时添加控件,
$('#MSvideo').hover(function toggleControls() {
if (this.hasAttribute("controls")) {
this.removeAttribute("controls")
}
else {
this.setAttribute("controls", "controls")
}
});
从理论上讲,它可以在悬停时添加控件,但是如果你把鼠标放在视频上,鼠标就会继续运行,然后关闭,然后关闭,大约每秒重复一次。
它在这个小提琴上做同样的事情,http://jsfiddle.net/konbsda8/
任何帮助都将不胜感激!
发布于 2014-11-13 00:07:52
好的,我知道了,controls属性需要是空的,所以行
this.setAttribute("controls", "controls")
反而应该是
this.setAttribute("controls", "")
这似乎解决了闪烁效应。
https://stackoverflow.com/questions/26898760
复制相似问题