0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

jQueryで値を取得、設定、変更する方法

Posted at

値の取得方法

HTML

<button id="btn-a" value="aaa">ボタンA</button>

jQuery

var a = $(#bta-a).val();
cousole.log(a);

実行結果

aaa

値の設定方法

HTML

<button id="btn-a">ボタンA</button>

JQuery

$('#btn-a').val('aaa');

実行後のボタン要素

<button id="btn-a" value="aaa">ボタンA</button>

値の変更方法

HTML

<button id="btn-a" value="abc">ボタンA</button>

jQuery

$('#btn-a').val('aaa');

実行後のボタン要素

<button id="btn-a" value="aaa">ボタンA</button>

まとめ

・val()メソッドを使用することで値を取得、設定、変更ができる

参考文献

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?