все еще возникают проблемы - если я получу свой код для воспроизведения выбранного аудио, кнопки не будут переключаться. Если я включу $(document).ready(function(){
, то кнопка переключается, но звук не воспроизводится! Кто-нибудь может спасти маленькие волосы, которые у меня остались? Это HTML5 jQuery Mobile проект для доставки на iOS 5
Спасибо за любую помощь
J
Код:
$(document).ready(function(){
var selSound = '18000'; //default to first sound.
var play = false; //default to paused.
function selectSound(id) {
selSound = id;
}
$('#playbtn').click(function() {
var $this = $(this);
var a = document.getElementById(selSound);
if($this.text() == 'Zap!') {
$this.children().children().text('Stop');
a.play();
} else {
$this.children().children().text('Zap!');
a.pause();
alert('Stopped playing song: '+selectedMP3);
}
});
})
HTML:
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" >
<li data-swatch="b" class="ui-li ui-li-divider ui-btn ui-bar-a ui-corner-top" data-role="list-divider" role="" data-form="ui-bar-b">Select a frequency</li>
<input type="radio" name="mp3_option" id="selectSound('16000')" onclick="selectSound('16000')"><label for="selectSound('16000')">16Hz</label>
<input type="radio" name="mp3_option" id="selectSound('18000')" onclick="selectSound('18000')"><label for="selectSound('18000')">18Hz</label>
<input type="radio" name="mp3_option" id="selectSound('20000')" onclick="selectSound('20000')"><label for="selectSound('20000')">20Hz</label>
</fieldset>
<div style="text-align:center"><a href="#" data-role="button" data-inline="true" id="playbtn">Zap!</a></div></div>