Oscar Mateu
Oscar Mateu

Reputation: 809

How to change jquery button icon

I have a button right this:

        <button type="submit" class="btn blue pull-right" id="RequestNewPwd">
           Submit <i class="m-icon-swapright m-icon-white"></i>
        </button>

With a text and an icon. I'm trying to change the text and the icon like via javascript like this:

            $("#RequestNewPwd").button({
                label: "Sent",
                icons: {
                    primary: "m-icon-swapleft  m-icon-white",
                }
            })

But it does not work. I also tried:

$("#RequestNewPwd").text('Submit <i class="m-icon-swapright m-icon-white"></i>');

And it prints the html code like text. This works:

$("#RequestNewPwd").text('Submit'); 

But I need to show also the icon. Could someone help me? Thank you!

Upvotes: 2

Views: 288

Answers (2)

Milind Anantwar
Milind Anantwar

Reputation: 82231

As you are appending html,you need to use .html() instead of .text():

$("#RequestNewPwd").html('Submit <i class="m-icon-swapright m-icon-white"></i>');

Upvotes: 3

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67187

You have to use .html() to render the string into html elements.

Try,

$("#RequestNewPwd").html('Submit <i class="m-icon-swapright m-icon-white"></i>');

Upvotes: 3

Related Questions