Get me outta here!

marcalbert

This website is meant for developers to help and show them interesting things about Html, CSS, JavaScript and Java languages.

Menu

Skip to content
  • Home
  • About
  • What is jQuery?

Tag Archives: checkbox

How to change the value of a check box onClick using JQuery?

03/18/2013 by marcalbert

With this code, you can change the value of the check box to 1 when it is checked, or to 0 when it is unchecked:

The HTML:

<input type="checkbox" id="read" onClick="" />
  1. You should do this:
    onclick="$(this).attr('value', this.checked ? 1 : 0)"
  2. Or even:
    onclick="$(this).val(this.checked ? 1 : 0)"
JavaScript jQuery checkboxinput type Leave a comment

Post navigation

Archives

  • June 2015
  • March 2015
  • December 2014
  • September 2014
  • March 2014
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • March 2013

Meta

  • Register
  • Log in
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • marcalbert
    • Already have a WordPress.com account? Log in now.
    • marcalbert
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar