嗨,我正在研究一个应该触发另一个按钮的按钮,但它似乎不起作用。(触发器代码在底部)
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="google-tts.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
if (!window.GoogleTTS) {
$("#error").text("Sorry, the google-tts script couldn't be loaded.");
return;
} else {
var HTML = '\
<div> \
<label for="demo_language">Language:</label> \
<select id="demo_language"> \
<option value="" disabled="disabled">(Select language)</option> \
</select> \
</div> \
<div> \
<label for="demo_text">Text:</label> \
<input type="text" size="30" id="demo_text" value=""> \
</div> \
<button id="demo_play">Play!</button> \
<div id="testbutton">\
<form id="target" method = "post">\
<button id="go">Go!</button>\
</form>\
</div>\
';
$("#tts_demo").html(HTML);
}
var googleTts = new window.GoogleTTS();
// setup language options
$.each(googleTts.languages(), function(key, value) {
$('#demo_language').append('<option value="' + key + '">' + value + '</option>');
});
// play
$("#demo_play").click(function() {
googleTts.play($("#demo_text").val(), $("#demo_language").val(), function(err) {
if (err) {
alert(err.toString());
}
});
});
// defaults
$("#demo_language").val('zh-CN');
$("#demo_text").val('中文');
$("#go").click(function () {
$("#demo_play").trigger('click')
alert('one')
})
});
</script>
有趣的是,触发似乎跳过了,它直接进入警报。我似乎无法弄清楚如何使它工作。请帮忙?