LoginSignup
2
3

More than 5 years have passed since last update.

まとまった数の<input type='text .... をclassでグループ指定する

Posted at

<input type='text .... がまとまった個数ありグループ分けしたいときなどは、グループ毎にclassでまとめると楽ちん!

<!-- グループ1 -->
<input type="text" class="group1" name="hoge1">
<input type="text" class="group1" name="hoge2">
<input type="text" class="group1" name="hoge3">
<input type="text" class="group1" name="hoge4">

<!-- グループ2 -->
<input type="text" class="group2" name="fuga1">
<input type="text" class="group2" name="fuga2">
<input type="text" class="group2" name="fuga3">
<input type="text" class="group2" name="fuga4">

jQueryで指定するときグループ1、グループ2はそれぞれ次のように指定できる

//グループ1
$("input[type='text'].group1")

//グループ2
$("input[type='text'].group2")

ちょっととまどったので、おぼえがき・・

2
3
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
2
3