1 回答
TA贡献1865条经验 获得超7个赞
像这样的东西吗?
$(document).ready(function() {
$('#getCheckboxesButton').on('click', function(event) {
var checkboxValues = [];
$('input.eret[type="checkbox"]:checked').each(function(index, elem) {
checkboxValues.push('Color:"' + $(elem).val() + '"');
});
$('#debugOutput').html(checkboxValues.join(','));
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input class="eret" type="checkbox" value="Red">Red
<input class="eret" type="checkbox" value="Green">Green
<input class="eret" type="checkbox" value="Blue">Blue
<input class="eret" type="button" value="Get checkboxes" id="getCheckboxesButton">
<div id="debugOutput">
</div>
- 1 回答
- 0 关注
- 77 浏览
添加回答
举报