Home Forums General Discussions Check if a checkbox is checked using jQuery

Viewing 1 post (of 1 total)
  • Author
  • #550
    Usman Haider

    I came across using multiple checkboxes in my page and needed to check if a status of the given checkbox is checked or unchecked. After searching a bit, i found it and thought to share it with you. Suppose we have four check boxes, each with a unique ID assigned to it. Here is how we will check the status of first check box whose ID is “check_box1”:

    Method 1:

    The above method will work only with jQuery version 1.6 or higher.

    The output of above code will be:

    checked (if check box is checked).

    undefined (if check box is unchecked).

    Method 2:

    The output of the above method will be:

    true (if checked)

    false (if not checked)

    Checking Multiple Checkboxes:

    The above two methods are only for checking status of a single checkbox. Following code can be used for checking multiple check box status:

    Hope it might help you.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.