-1
function(response) {                    
    if(1 == response) {
        if(type=='favorite'){
            thelink.text('<?php _e('Rem Portfolio', 'sp-favorite-groups'); ?>');
            thelink.addClass('unfavorite-group').removeClass('favorite-group');
        } else {
            thelink.text('<i class="icon-bell"></i><?php _e('Add Portfolio', 'sp-favorite-groups'); ?>');
            thelink.addClass('favorite-group').removeClass('unfavorite-group');
        }
    } else {
        alert(response);
    }
}

I have a function/plugin that changes the text inside a button. How do I include icon to the text? Eg

 thelink.text('<i class="icon-bell"></i><?php _e('Rem Portfolio', 'sp-favorite-groups'); ?>');

Obviously that doesnt work as the browser shows all the html tags instead of the actual icon.

Vinit Divekar
  • 774
  • 10
  • 24
Phi Cao
  • 15
  • 6
  • `text()` inserts what you give it as a text node, which is why you see the html. If you want what you give it to render as markup, you have to use `html()` or just `append()` the new markup. – Taplar Sep 11 '18 at 22:08
  • that makes sense cheers – Phi Cao Sep 11 '18 at 22:15

1 Answers1

0

As @Taplar pointed out, used html() instead;

thelink.html('<i class="icon-bell"></i> Button name');
Phi Cao
  • 15
  • 6