jQueryでのselectのvalueの取得方法がわからず、質問させていただきます。
現在SpringBoot + jQuery + ajaxを使ったsampleを練習のため自分で作成しています。
現状htmlのコードが
html
1<select id="select"> 2<option th:each="hoge : ${fooMap}" th:text="${hoge.value}" th:value="${hoge.key}"> 3</select> 4<select id="select"> 5<option th:each="hoge : ${fooMap}" th:text="${hoge.value}" th:value="${hoge.key}"> 6</select> 7<select id="select"> 8<option th:each="hoge : ${fooMap}" th:text="${hoge.value}" th:value="${hoge.key}"> 9</select> 10<select id="select"> 11<option th:each="hoge : ${fooMap}" th:text="${hoge.value}" th:value="${hoge.key}"> 12</select>
このような形で記述しており、このselectのvalueを一度に取得したいと考えています。
(同じ内容をもつselectBoxが4つ並んでいるイメージです)
jQuery
1 2var sample = $('select').val(); 3
のような形でselectのvalueを取得しようとすると最初の一つのvalueが送られる状態です。
これをsampleに{1,2,3,4}といった具合に一度の取得で複数の値をsampleに入れる方法がわからず、質問させていただきます。
初学者でわからないことも多く、質問させていただきます。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/25 01:01