LoginSignup
7
7

More than 5 years have passed since last update.

jQueryMobile でボタンのテキストを書き換える

Posted at

JavaScript でボタンのテキストを動的に書き換えたくなることは多々ある。
jQuery Mobile を使用していて、Button の中身の書き換え方で、少し手間取ったので、メモを残す。

仮に

<a id="button" href="#" data-role="button">hoge</a>

のようなボタンを作り、JavaScript で hoge を fuga に変えたくなった場合、

$('#button .ui-btn-text').text("fuga");

とすればよい。クラスとして、ui-btn-text を指定ないと、テキストは変わるがボタンのサイズがおかしくなってしまう。

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7