页面上的两个jQuery应用程序一次只能工作一个?
问题描述:
我遇到了一个正在处理的网站问题。 http://petersea*.com/galaxias2/。页面上的两个jQuery应用程序一次只能工作一个?
我有两个JavaScript脚本执行一些jQuery,但只有1将工作在一个时间取决于哪些代码首先为时钟或jPlayer无线电。
我不知道该怎么办。
CODE:
jQuery(document).ready(function($){
$('#clock_sydney').jClocksGMT({offset: '+11'});
$('#clock_greece').jClocksGMT({offset: '+3'});
});
jQuery(document).ready(function($){
var stream = {
title: "Galaxias Radio",
mp3: "http://78.46.52.186:18272/;/stream/1"
},
ready = false;
$("#jquery_jplayer_1").jPlayer({
ready: function (event) {
ready = true;
$(this).jPlayer("setMedia", stream);
},
pause: function() {
$(this).jPlayer("clearMedia");
},
error: function(event) {
if(ready && event.jPlayer.error.type === $.jPlayer.error.URL_NOT_SET) {
// Setup the media stream again and play it.
$(this).jPlayer("setMedia", stream).jPlayer("play");
}
},
swfPath: "http://petersea*.com/galaxias2/wp-content/themes/canvas/js/jplayer",
supplied: "mp3",
preload: "none",
wmode: "window",
useStateClassSkin: true,
autoBlur: false,
keyEnabled: true
});
$("#jplayer_inspector").jPlayerInspector({jPlayer:$("#jquery_jplayer_1")});
}); 在此先感谢你们,
Peter。
答
你调用了两个函数吗?如果不是的话,你可以同时调用两个函数。
function twoFunctions(){0} { firstFunction(); secondFunction();
}
+0
你可能会向我展示我在编辑中提供的代码吗? – 2015-02-06 02:15:07
我不知道它是否会影响到您,但JavaScript是单线程的:只有一个代码在给定的时间运行。 – 2015-02-06 01:45:52