English 中文(简体)
如何在播放视频时卸载窗口
原标题:how to unbind click while a video is playing

我在一个阵列中有一组按钮, 我想要它, 这样当您单击一个按钮, 以及它链接到的视频开始播放时, 它会解开按钮上的 < code> 点击 键( 最好是您刚刚点击的那个按钮, 但我甚至不能让它为 < code>li 工作) 。

$("#myVid").bind("playing", function() {
  //some stuff that happens
  $("li", ".thumbs").unbind( playVideo() )
        });

但它不起作用... 我在这里做错什么了? ( playVideo () 是已经定义的函数)

Just to be more specific:
the problem is that it s supposed to unbind only once the video is playing, hence the .bind("playing", function().... I can get it deactivate the list, but its before it should...
最佳回答

如果你们这样创造了这个事件,

$("li", ".thumbs").bind("click", playVideo);

采取相反行动就是:

$("li", ".thumbs").unbind("click", playVideo);

用于绑定单击事件时,必须使用相同的函数来删除同一事件。

function click() {
    $("#myVid").bind("loadeddata", function() {
    $("#bigPic").addClass("move");
    $("#MyT").fadeOut(750);
            });
    playVideo( $(this).index() );
}

$( li ,  .thumbs ).bind( touchend click , click);

$("#myVid").bind("playing", function() {
    $( li ,  .thumbs ).unbind( touchend click , click);
});
问题回答

您是否查看了 < a href=" "http://api.jquery.com/ unbind/" rel="nofollow"\\\ code>. unbind () doco ? 您必须传递您没有约束力的事件的名称( 虽然有超载, 您可以通过事件对象) 。 尝试 :

$("li", ".thumbs").unbind( click );

您可以选择将引用到特定处理器的引用传送到 unbind :

$("li", ".thumbs").unbind( click ,playVideo);

后者是必要的,如果你对多个处理者具有约束力, 并且只想解开一个特定的处理者。

(如果使用jQuery 1.7版本或以后我建议使用 .off () 方法 。 )





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签