Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change a button text in jQuery mobile [duplicate]

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

like image 321
user123_456 Avatar asked Dec 18 '25 17:12

user123_456


2 Answers

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>?

like image 165
Alejo Avatar answered Dec 21 '25 10:12

Alejo


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.

like image 30
Arpit Srivastava Avatar answered Dec 21 '25 09:12

Arpit Srivastava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!