我想遍历复选框组'locationthemes'并构建一个包含所有选定值的字符串。当复选框2和4被选为 那么结果将是:“3,8”使用jQuery获取所选复选框的值
<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/但有没有例子,如何选择由它的名字checkboxgroup。
我该怎么做?
你,我的朋友,是一个拯救生命的人。 – Haring10
尤其我喜欢使用控制台日志的想法。感谢那。 –