mastersuse
mastersuse

Reputation: 988

How to replace Delete word with Font Awesome in jQuery

I am trying to replace Delete word with Font Awesome icon in jQuery. I have googling and searching but not find any solution.

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>";     
    } }
],

Font Awesome

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

Upvotes: 2

Views: 90

Answers (1)

Amin Kodaganur
Amin Kodaganur

Reputation: 666

You can directly have your icon code in your render return string like below

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>";     
}

But only thing when you rendering this element in DOM then you should use html method of jquery like below

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

Upvotes: 2

Related Questions