The delete
button is disabled when the page load. There are multiple checkboxes on the form and when a user clicks a checkbox then the delete
button change to enable. When a user unchecks the checkbox (didn't select any checkbox) then the delete
button change to disabled. Also, all the selected checkbox value will be assigned to an input field separated by a comma.
Below code is working fine in chrome. But it's not working fine in Safari. In Safari user need to check, uncheck again they have to check (third time) or when they select the second checkbox then only the delete
button change to enabled and the selected value is displaying in the input field. I don't know whats wrong with this code.
Please check this demo in Chrome and Safari you will get it.
$(document).on(click, .imgtitleclick, function (e) {
$checks = $('.imgtitleclickmodal');
$checks.on('change', function() {
var string = $checks.filter(':checked').map(function(i,v){
return this.value;
}).get().join(',');
$('.hiddenimgnumdis').val(string);
$('.hoverforport-img-del').prop('disabled', $checks.filter(':checked').length < 1);
});
})
<script src=https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js></script>
<button class=btn-danger hoverforport-img-del floatright disabled data-toggle=modal data-target=#confirm-delete-portfolio>Delete</button>
<ul class=photo-grid lightgalleryselector>
<div class=col-sm-4 col-xs-6 col-md-3 col-lg-3 shw mblpad hoverforport-img>
<label class=width100 editbtnprofilea nopadd posabsol imgtitleclick color5 for=1>
<input type=checkbox value=1 class=imgtitleclickmodal id=1>
</label>
</div>
<div class=col-sm-4 col-xs-6 col-md-3 col-lg-3 shw mblpad hoverforport-img>
<label class=width100 editbtnprofilea nopadd posabsol imgtitleclick color5 for=2>
<input type=checkbox value=2 class=imgtitleclickmodal id=2>
</label>
</div>
</ul>
<input type=text class=hiddenimgnumdis/>