这是我的html:
<input class="eret" type="checkbox" value="Red">Red</input>
<input class="eret" type="checkbox" value="Green">Green</input>
<input class="eret" type="checkbox" value="Blue">Blue</input>
<input class="eret" type="button" value="Get checkboxes" id="getCheckboxesButton"></input>
<div id="debugOutput">
</div>
这是我的 JavaScript:
$(document).ready(function() {
$('#getCheckboxesButton').live('click', function(event) {
var checkboxValues = [];
$('input.eret[type="checkbox"]:checked').each(function(index, elem) {
checkboxValues.push($(elem).val());
});
$('#debugOutput').html(checkboxValues.join(','));
});
});
如何使用此输出定义 Javascript 代码?
输出(示例):
Color:"Green" --> One : Without Comma
Color:"Green",Color:"Blue" / Color:"Red",Color:"Green",Color:"Blue" --> Multi : With Comma
https://i.stack.imgur.com/iFyWT.png
鸿蒙传说
相关分类