我有一个视频数组,然后是一个与数组对应的拇指列表。当您单击其中一个按钮时,需要在视频持续时间内停用它。我有它,所以在第一次点击后,它会停用整个列表
$('li', '.thumbs').on('touchend click', function() {
$("#myVid").on("loadeddata", function() {
$("#bigPic").addClass("move");
$("#MyT").fadeOut(750);
});
playVideo2( $(this).index() );
$('li', '.thumbs').unbind();
});
如果列表中的每个项目都设置如下:
<li rel='1' id="first">
<div style="top:0px;">
<img src="graphics/filler.png" alt="" width="280" height="128" />
</div>
</li>
每个ID都不同,我可以只放id
而不是.thumbs
,只需要unbind
或转off
本身吗?我知道这一定是低效的,但我不知道该怎么做。我是否以某种方式使用this()
?如果是这样,如何?
答案 0 :(得分:1)
您可以使用全局变量来检查正在播放的视频。
//init
var currentlyPlaying = undefined;
在事件处理部分中,您将此变量设置为单击按钮的ID。
currentlyPlaying = $(this).attr('id');
使用该设置,您可以在脚本中执行任何操作之前检查变量。
if ( !(currentlyPlaying == $(this).attr('id')) ) {
// your script
}
或者,您可以按照建议使用ID取消绑定。
$('li', '.thumbs #' + $(this).attr('id')).unbind();