jquery 异步有道翻译API的声音路径 如何加载到 audio src?


jquery 异步有道翻译API的声音路径 如何加载到 audio src?

jquery php html5

诸神D黄昏 9 years, 9 months ago

加载到 audio jQuery 其实并没有多大关系..


 <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> 
 <audio id="hello" autoplay="true" controls="controls"></audio>


<script type="text/javascript">
    var audio = document.getElementById('hello');

    audio.src = 'http://dict.youdao.com/dictvoice?audio=hello&type=1';

    setTimeout(function(){
        $('#hello').attr('src', 'http://dict.youdao.com/dictvoice?audio=world&type=1');
    }, 3000);
  </script>

预览地址: http://jsbin.com/jolunuxiho/1/

一盆新的米露 answered 9 years, 9 months ago

Your Answer