2

Possible Duplicate:
change text on button using jquery mobile.

I need to change a button text, I am using jQuery mobile.

Here is my html:

<fieldset>
    <div><button type="submit" id="login_var">Login</button></div>
    <div><button type="reset" >Reset</button></div>
</fieldset>

I have tried all of the examples on this page: LINK and nothing is working for me.

Please help

Community
  • 1
  • 1
user123_456
  • 5,635
  • 26
  • 84
  • 140

2 Answers2

6

Yeah you can use

$(function(){
  $('#login_var').text('Ok').button('refresh');
});

As per http://jquerymobile.com/test/docs/buttons/buttons-methods.html, there are only three methods you can call on a button.

Arpit Srivastava
  • 2,249
  • 1
  • 16
  • 28
6

I've had to do the same thing before, it's really not as obvious to do as it should be. Since jQM adds span tags inside your button, you need to change the value inside the span:

$("#login_var .ui-btn-text").text("NewText");

Similarly, if you wanted to change the icon, you could do:

$("#login_var .ui-icon").removeClass("ui-icon-arrow-l").addClass("ui-icon-arrow-r");

Edit: Sorry I just noticed the link you posted in the question has the same solution, and you said that doesn't work for you. Maybe if you changed your buttons to

<a data-role="button"></a>

Instead of <button></button>?

Alejo
  • 1,913
  • 3
  • 26
  • 44