Search

[jQuery] How to Get Checked Checkbox Values and Store Them in an Array

Tadashi Shigeoka · Thu, September 19, 2013

Memo on how to get checked checkbox values and store them in an array with jQuery.

 春
 夏
 秋
 冬

The code to get the values of checked checkboxes and store them in an array is as follows:

var checkedSeasons = [];
$('[name="seasons"]:checked').each(function(){
  checkedSeasons.push($(this).val());
});

Reference Information

・jQueryでチェックされたcheckboxの値を取得して配列に格納する方法、また、配列をcheckboxの値に設定する方法 - knt45の日記

That’s all from the Gemba.