切換複選框值不起作用。當點擊該複選框,輸入字段的值設置爲1。當我再次單擊該值應爲空白切換複選框值
<div class="GruppoCheck">
<input type="checkbox" value="1"/>
</div>
<div id="checkMonitor"></div>
<div id="checkMonitorNUMBER"></div>
<div id="test"></div>
JS:
var CheckFUN = function() {
var numberCheckedVAR = $('input:checkbox:checked').length;
var $checkMonitor = $('#checkMonitor').empty();
$('.GruppoCheck :checkbox:checked').each(function(index) {
if(index == 0){
$checkMonitor.append($(this).val());
var val = $(this).val();
}
$('#test').html('<input type="text" id="testi" value="'+val+'"> ');
});
}
$('input[type="checkbox"]').change(function(){
CheckFUN();
});
什麼是checkMonitor元素? – 2015-02-09 12:50:36
請檢查http://jsfiddle.net/w5dqq6us/ – 2015-02-09 13:01:54