Jquery checks whether the check box is selected. jquery is selected.
Jquery judges whether the check box is selected and how to select it.
Enter the subject, or when there is a set of check boxes on the page:
<Input type = "checkbox" name = "fruit" value = "apple"/> apple <input type = "checkbox" name = "fruit" value = "orange"/> orange <input type = "checkbox" name = "fruit" value = "banana"/> banana <input type = "checkbox" name = "fruit" value = "grape"/> grape
You can use Jquery to obtain the value of a set of check boxes with name = fruit as follows:
Var checkVal = ''; $ (" input [name = 'fruit']: checkbox "). each (function () {if ($ (this ). attr ('checked') {checkVal + = $ (this ). val () + ',' ;}}) Determine whether the check box of name = fruit group has the selected option: var flag = false; $ ("input [name = 'fruit']: checkbox "). each (function () {if ($ (this ). attr ('checked') {flag = true ;}}) if (flag) {alert ('selected ');} else {alert ('no option selected ');}
The above is the method used by jquery to determine whether the check box is selected. I hope it will be helpful for you to learn and obtain it using js. For details, refer to JS to determine whether the check box is selected for an instance.