2012-05-31 48 views
0

我拥有它,所以当你点击右上角的氢元素时,它会在大中心div中播放视频并显示有关氢气的信息。我在当地工作,但我无法让它在网上工作。 请任何帮助将是伟大的。本地工作但不在线

这里是链接到我的项目 http://travismichael.net/periodic_elements/

这里是我的地盘

<script type="text/javascript"> 
$(document).ready(function() { 


$('div.video').hide(); 

$('.icon').click(function(){ 
    var id=$(this).data('id'), 
     thisDiv=$("div.video[data-id='" + id +"']"), 
     thisVideo=$("div.video[data-id='" + id +"']").find('video'); 

    $('video').each(function() { 
     this.pause(); 
     this.currentTime = 0; 
    }); 

     $('div.video').not(thisDiv).fadeOut('fast'); 

     thisDiv.fadeIn();  
     thisVideo.get(0).play(); 
    }); 

}); 
</script> 
<script type="text/javascript"> 
$("#periodictable td").hover(function() { 
     $(this).stop().animate({opacity: "1"}, 'fast'); 
    }, 
    function() { 
     $(this).stop().animate({opacity: ".7"}, 'slow'); 
    }); 
</script> 
+0

你的控制台出现了什么错误? –

+0

'$('video')。each'正在抛出'未捕获错误:INVALID_STATE_ERR:DOM异常11' – jbabey

回答

0

脚本时检查我得到的说,元素是未定义的错误消息。

你应该过去控制台给你的错误,因为它会给你更多的解释。

这显然是抛出一个异常,无论你的例外是显示错误信息,所以......你在你的本地主机上试图定义文件。它们是在你的代码中用一个指针还是某个东西来声明的?在这里点击这个按钮并点击按钮来使用它?

它看起来像你的函数应包含这些声明,或者你可以让他们全球性的,真的不知道没有更多的信息.​​..

+0

如果您想再次查看,我更新了代码。 – travis5567

+0

我在本地使用MAMP以及使用尾声的预览模式(我非常确定使用safari webmx)。当我尝试在线打开它时,它不会工作。 – travis5567

1

错误是在这里:

你跟

努力
var thisDiv = ("div.video[data-id='" + id +"']");// but it returns jQuery object, 
               // not element 

// Thats why below statement will not work 
// because it works on element 

alert(thisDiv.nodeType); 

所以,你应该尝试这样的:

var thisDiv = ("div.video[data-id='" + id +"']")[0]; // returns the element 
alert(thisDiv.nodeType); // and then get the nodeType 
相关问题