如何在 jQuery 中用 Font Awesome 替换 Delete word

How to replace Delete word with Font Awesome in jQuery

我正在尝试用 jQuery 中的 Font Awesome 图标替换 Delete 字词。我进行了谷歌搜索,但没有找到任何解决方案。

JS

columns: [
    { "data" : "filename", 
           render: function ( data ) {
           return "<span onclick='download_file(&quot;"+data+"&quot;)'>Download</span> / <span onclick='delete_file(&quot;"+data+"&quot;)'>Delete</span>";     
    } }
],

字体很棒

<i class="fa fa-trash" aria-hidden="true"></i>

您可以直接在您的渲染器中包含您的图标代码 return 字符串,如下所示

render: function ( data ) {
       return "<span onclick='download_file(&quot;"+data+"&quot;)'>Download</span> / <span onclick='delete_file(&quot;"+data+"&quot;)'><i class='fa fa-trash' aria-hidden='true'></i></span>";     
}

但是只有当你在 DOM 中渲染这个元素时,你才应该使用 jquery 的 html 方法,如下所示

$('Your Selector').html(render_function_call);