我想遍历复选框组“ locationthemes”,并使用所有选定值构建一个字符串。所以,当复选框2和4被选出的结果将是:“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>
我在这里检查过:http : //api.jquery.com/checked-selector/,但是没有示例如何通过其名称选择复选框组。
我怎样才能做到这一点?