<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title></title> <script src="jquery-2.1.4.min.js"></script> </head> <body> <audio src="" controls="controls" preload id="music"></audio> <script> function loadAudio(src, callback) { var audio = new Audio(src); audio.onloadedmetadata = callback; audio.src = src; } var audioUrl = "a.mp3";//音频路径 //调用方法 loadAudio(audioUrl,function(){ $('#music').attr("src",audioUrl); alert("加载完成"); }); </script> </body> </html>