1 <div id="prm_div" style="font-size: 12px;" align="left">2 <form id="cx" method="post">3 <s:iterator var="item" value="#request.optionPrm" status="status">4 <span><input class="btn1" type="checkbox" name="checkPrm" style="margin: 3px 1px 0px 3px;" value="${item.id }" ${item.checked } />${item.text }</span>5 </s:iterator>6 </form>7 </div>
Use jquery to determine whether checked is selected.
1 If ($ (". btn1"). Filter (": checked"). Length = 0) {2 alert ("the metric parameter cannot be blank. Please check it! "); 3}
Jquery: checkbox Selector
Jquery selector Reference Manual
Instance
Hide all <input> elements of type = "checkbox:
$(":checkbox")
Definition and usage
: The <input> element of the checkbox selector.
Syntax
$(":checkbox")
$ (": Checked") indicates the execution option selected
Checkbox application in HTML
Checkbox object
The checkbox object represents a selection box in an HTML form.
In the HTML document, <input type = "checkbox"> every time a checkbox object appears, it is created.
You can access a selection box by traversing the elements [] array of the form, or by using document. getelementbyid ().
Attributes of the checkbox object
Attribute |
Description |
Accesskey |
Set or return the shortcut key for accessing the checkbox. |
ALT |
Sets or returns the alternative text that does not support checkbox display. |
Checked |
Sets or returns whether the checkbox should be selected. |
Defaultchecked |
Return the default value of the checked attribute. |
Disabled |
Sets or returns whether the checkbox should be disabled. |
Form |
Returns a reference to a form containing the checkbox. |
ID |
Sets or returns the checkbox ID. |
Name |
Set or return the checkbox name. |
Tabindex |
Sets or returns the checkbox Tab key control order. |
Type |
Returns the form Element type of the checkbox. |
Value |
Sets or returns the value of the Value Attribute of the checkbox. |
Standard attributes
Attribute |
Description |
Classname |
Sets or returns the class attribute of an element. |
Dir |
Set or return the direction of the text. |
Lang |
Set or return the language code of the element. |
Title |
Sets or returns the title attribute of an element. |
Checkbox object Method
Method |
Description |
Blur () |
Remove the focus from the checkbox. |
Click () |
Simulate a mouse click in the checkbox. |
Focus () |
Assign focus to the checkbox. |