Check whether the check box is selected

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.