Home >Web Front-end >JS Tutorial >JavaScript sample code to limit the number of checkbox selections_javascript skills
There are 10 checkboxes, and the user can only check at most 3, otherwise all the checkboxes will be grayed out.
(When the user checks off the check box again, he can still select it again.)
Set the variable part as a JS parameter to achieve code reuse.
JS code
The first parameter is the name of the check box, and the second parameter is the maximum allowed check value.