I have 10 checkbox in my page and I want some code run after any checkbox checked. look at my code please:
var width = 0;
$('#checkbox1').change(function() {
if($(this).is(":checked")) {
width+=5;
}
else{
width-=5;
}
//this is the code that i want it run after any of checkboxes clicked
if (width <= 25){do something}
if ( width > 25 && width <= 50){do something}
if ( width > 50 && width <= 75){do something}
if ( width > 75 && width <= 100){do something}
});
Is there any way to create a function or something else to run these codes inside every checkboxes and prevent from repeating these codes?
'#checkbox1'is targeting only one of them. can you add a fiddle with your whole code?