Tôi muốn lặp qua nhóm hộp kiểm 'locationthemes' và tạo một chuỗi với tất cả các giá trị đã chọn. Vì vậy, khi hộp kiểm 2 và 4 được chọn, kết quả sẽ là: "3,8"
<input type="checkbox" name="locationthemes" id="checkbox-1" value="2" class="custom" />
<label for="checkbox-1">Castle</label>
<input type="checkbox" name="locationthemes" id="checkbox-2" value="3" class="custom" />
<label for="checkbox-2">Barn</label>
<input type="checkbox" name="locationthemes" id="checkbox-3" value="5" class="custom" />
<label for="checkbox-3">Restaurant</label>
<input type="checkbox" name="locationthemes" id="checkbox-4" value="8" class="custom" />
<label for="checkbox-4">Bar</label>
Tôi đã kiểm tra ở đây: http://api.jquery.com/checked-selector/ nhưng không có ví dụ nào về cách chọn nhóm hộp kiểm theo tên của nó.
Tôi có thể làm cái này như thế nào?