将下载链接添加到 Wordpress 默认音频播放器的代码已损坏

将下载链接自动添加到音频嵌入的代码曾经可以工作,现在,我突然收到错误消息,说 Uncaught TypeError: $ is not a function...


我完全不明白为什么


示例链接是https://mpmania.com/download-mp3/wizkid-ghetto-love-audio/


我使用了故障排除模式,停用了所有插件,更新了过时的插件,可能有人可以帮助重写这些代码以使其正常工作


$( document ).ready(function() {

    $('audio').each(function( index ) {


        var source = $(this).find('source').attr('src');


        if ( source != '' ) {

            $(this).after('<a href="' + source + '" class="audio-download" download>Download (Alternative)</a>');

        }


    });

});

我基本上希望它像以前一样工作


慕桂英546537
浏览 193回答 1
1回答

精慕HU

扩展我上面的评论,您的代码应如下所示:jQuery(function($) {     $('audio').each(function(index) {        var source = $(this).find('source').attr('src');        if (source != '') {            $(this).after('<a href="' + source + '" class="audio-download" download>Download (Alternative)</a>');        }    });});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript