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

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

WBOY
WBOYOriginal
2016-06-06 20:33:211076browse

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

回复内容:

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

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

<code> <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>



</code>

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn