[英]I'm using jquery and regular javascript on a page with no probs until I added one more function
Here's what I'm doing. 这就是我在做什么。
I have a few images on a page with an HTML5 audio player underneath each one and a select menu with a list of sounds. 我在一个页面上有一些图像,每个图像下面都有一个HTML5音频播放器,还有一个带有声音列表的选择菜单。
When a sound is selected from the menu, it places that sound in the source of the audio player. 从菜单中选择声音后,它将声音放置在音频播放器的来源中。
What I want to do is change the image to an animated gif when the sound is played. 我要做的是在播放声音时将图像更改为动画gif。
The onchange works fine loading the sound into the player. onchange可以很好地将声音加载到播放器中。 But when I add the new onplay() call, none of the javascript works. 但是,当我添加新的onplay()调用时,所有的javascript都不起作用。
function playPic(theid){ var leid = theid.replace('play',''); document.getElementById('leid'+pic).src="images/" + leid ".gif"; } $( function() { $( "#sortable" ).sortable(); $( "#sortable" ).disableSelection(); } ); $(document).ready(function() { $('#sortable').sortable(); //$('<br><br><div id=buttonDiv><button>Get Order of Elements</button></div>').appendTo('body'); //$('button').button().click(function() { $( "#sendgame" ).submit(function( event ) { var itemOrder = $('#sortable').sortable("toArray"); var fullOrder = ""; for (var i = 0; i < itemOrder.length; i++) { newi = i + 1; //alert("Position: " + i + " ID: " + itemOrder[i]); fullOrder += newi + " - " + itemOrder[i] + "<br>"; } //alert (fullOrder); document.forms["sendgame"].ordre.value = fullOrder; }) }); function recSon(lename, leson) { document.forms["sendgame"][lename].value = leson; } function loudSon(soundid, leplayer) { lesound = ""; if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { lesound = soundid + ".ogg"; } else { lesound = soundid + ".mp3"; } }
The playPic function is what screws everything up. playPic函数可将所有内容搞砸。 I've tried it in different places in the code but always the same error : 我已经在代码中的不同地方尝试过,但是总是相同的错误:
Uncaught ReferenceError: recSon is not defined at HTMLSelectElement.onchange (jeuhockeynoir.php?lang=f:481) onchange @ jeuhockeynoir.php?lang=f:481 未捕获的ReferenceError:在HTMLSelectElement.onchange(jeuhockeynoir.php?lang = f:481)上未定义recSon onchange @ jeuhockeynoir.php?lang = f:481
you're missing a +
sign: 您缺少一个+
号:
document.getElementById('leid'+pic).src="images/" + leid ".gif";
should be 应该
document.getElementById('leid'+pic).src="images/" + leid + ".gif";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.