English 中文(简体)
如何使这些职能停止干预
原标题:How to make these functions stop interfering

我有两个职能,一个在点击上播放录像(并改变拍摄的录像),而另一个职能是使DVD不透明。 我试图把他们聚集在一起,因为你本应在同一地点点点点点点点点点点点击,以启动两者,但却没有工作。

出于某种原因,当我把载有录像的四分五裂(甚至没有播放功能)时,第二功能停止工作。 届时我能做些什么?

录像机的作用是:

$(window).load(function(){
    $( li ,  .thumbs ).on( click , function() {
        var numb = $(this).index(),
            videos = [ images/talking1.m4v ,  images/talking2.m4v ,  images/talking1.m4v ,  images/talking2.m4v ,  images/talking1.m4v ,  images/talking2.m4v ],
            myVideo = document.getElementById( myVid );

        myVideo.src = videos[numb]; 
        myVideo.load();
        myVideo.play();

    });
});

形象:

$(window).load(function(){
    $(function() {
        $( li ,  .thumbs ).click(function() {
            $( #MyT ).addClass( clear );
        });
    });
});

我知道,这两条带的编号为$(window),(功能),这只是因为它们是单独的。

最佳回答

你们是否相信你们的多位选择子是你们想要的吗? 如果你想将其应用于所有这些因素,那么,你就不得不仅仅通过<条码>。 不管怎样,我通常认为情况是不必要的,除非是我以前担任过要职的遴选人。 http://api.jquery.com/multiple-selector/"rel=“nofollow”

$( li, .thumbs ) // All `li` and all `.thumbs`
$( .thumbs li ) // All  li` within `.thumbs`

通知你也使用<代码>(窗口)。 如果两者合在一起,则彼此选择。 http://4loc.wordpress.com/2009/04/28/documentready-vs-windowload/“rel=“nofollow”>。 然后,你可以把一切照样结合起来,应该工作。

$(document).ready(function () {

    $( li, .thumbs ).on( click , function () {

        // Add class
        $( #MyT ).addClass( clear );

        // Video stuff
        var numb = $(this).index(),
            videos = [
                 images/talking1.m4v ,
                 images/talking2.m4v , 
                 images/talking1.m4v , 
                 images/talking2.m4v , 
                 images/talking1.m4v , 
                 images/talking2.m4v 
            ],
            myVideo = document.getElementById( myVid );
            myVideo.src = videos[numb];

        myVideo.load();
        myVideo.play();

    });

});
问题回答

If his doesn t work, separate the functions and call them with window.onload(*function*).

与此类似:

function vP() {
   $( li ,  .thumbs ).on( click , function() {
      var numb = $(this).index(),
      videos = [ images/talking1.m4v ,  images/talking2.m4v ,  images/talking1.m4v ,  images/talking2.m4v ,  images/talking1.m4v ,  images/talking2.m4v ],
      myVideo = document.getElementById( myVid );
      myVideo.src = videos[numb]; 
      myVideo.load();
      myVideo.play();
   });
}
function iM() {
   $( li ,  .thumbs ).click(function() {
      $( #MyT ).addClass( clear );
   });
}
window.onload(iM();vP();)

为什么不把两者同起来呢? 我怀疑,你的点击事件处理者之一可能会凌驾于另一个点击手,并造成他无法登记。

$(window).load(function(){
    $( li ,  .thumbs ).on( click , function() {
        var numb = $(this).index(),
            videos = [ images/talking1.m4v ,  images/talking2.m4v ,  images/talking1.m4v ,  images/talking2.m4v ,  images/talking1.m4v ,  images/talking2.m4v ],
            myVideo = document.getElementById( myVid );
        myVideo.src = videos[numb]; 

        myVideo.load();
        myVideo.play();

        $( #MyT ).addClass( clear );
    });
});




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签