我想用相应的声音突出显示特定的段落/列表。
responsivevoice.js 中是否有任何回调。我将 onend 作为回调函数。但它不起作用。
每当我放置 console 而不是 highlight 时,它只会产生一个而不是三个。
我认为 onend 只在第一个 para 之后调用。但它应该适用于所有 para/ul
请帮帮我。。
我的代码:-
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="http://code.responsivevoice.org/develop/1.5.2/responsivevoice.js"></script>
<script>
var currentDataValue =0;
$( document ).ready(function(){
$("#1").click(function(){
$("p,ul").each(function( index, element){
responsiveVoice.speak($(this).text(),$('UK English Female').val(),{
pitch: .7,
onend: function() {
$(this).css( "backgroundColor", "yellow" );
}
});
});
});
});
$( document ).ready(function(){
$("#2").click(function(){
responsiveVoice.pause();
});
});
$( document ).ready(function(){
$("#3").click(function(){
responsiveVoice.resume();
});
});
$(window).load(function(){
$("#4").click(function(){
responsiveVoice.cancel();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<ul>
<li>this unoder list </li>
</ul>
<p id="test">This is another paragraph.</p>
<button id="1">start</button>
<button id="2">pause</button>
<button id="3">resume</button>
<button id="4">stop</button>
</body>
</html>