4
我一直在嘗試一個星期來創建一個動態jplayer,這取決於選擇框中所選的選項而變化。其他堆棧溢出帖子非常有幫助,所以我希望我能夠弄清楚這一點。任何與其他人已經完成的例子的鏈接也將被讚賞。在相關的JavaScript低於:動態jPlayer
jQuery(document).ready(function($){
$(function() {
var pinyinTone=null;
var toneSelect=null;
var pinyinSound=null;
$("#jquery_jplayer").jPlayer({
ready: function() {
},
swfPath: "/sites/all/libraries/jplayer/js",
supplied: "mp3"
})
$("#jquery_jplayer").jPlayer("setMedia", {
mp3: '/sites/default/files/pinyinSound/' + pinyinTone + '.mp3',
wav: '/sites/default/files/pinyinSound/' + pinyinTone + '.wav'
});
};
$("select#pinyinSound").change(function(){
toneSelect=1;
$('#toneSelectDiv').show();
pinyinSound=$(this).val();
$.ajax({
url: "/HBCAppFiles/get_list.php",
data: {
pinyinSound: $("select#pinyinSound").val()
},
dataType:"json",
success:function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
}
$("select#toneSelect").html(options);
}
})
pinyinTone=pinyinSound + toneSelect;
processPinyinVars(pinyinTone);
});
$("img#pinyinSliderPlayButton").click(function(){
$('#inner').animate({width: 250}, function(){ $(this).width(0)});
$("#jquery_jplayer").jPlayer("play");
return false;
});
})(jQuery);
你可以縮進你的代碼嗎? – Reinard 2012-03-26 14:08:38
當我的代碼縮進超過4個空格時,Stack Overflow抱怨... – 2012-03-28 02:01:11