Sign Up

Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In


Have an account? Sign In Now

Sign In

Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
Home/ Questions/Q 4883
Next
In Process

Oraask Latest Questions

Question
Saly
  • 0
  • 0
SalyExplorer
Asked: March 27, 20172017-03-27T09:50:30+03:00 2017-03-27T09:50:30+03:00In: JavaScript

How to set a checkbox to be “checked” and “uncheck” with JQuery 1.5 & 1.6 ?

  • 0
  • 0

Hi just like the title I want to do this by JQuery please.

checkboxcheckedjavascriptjqueryuncheck
1
  • 1 1 Answer
  • 763 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Related Questions

    • Set form control value in angular
    • How do I append more elements after clicking in react
    • How can we add margin left to badge in Angular material
    • How can we add bootstrap to Angular project
    • How to bound a state variable to a field react final form

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. Googler
      Googler Explorer
      2018-04-01T21:23:06+03:00Added an answer on April 1, 2018 at 9:23 pm

      jQuery 1.6+

      Use the new .prop() method:

      [code]$(‘.myCheckbox’).prop(‘checked’, true);
      $(‘.myCheckbox’).prop(‘checked’, false);[/code]

      jQuery 1.5.x and below

      The .prop() method is not available, so you need to use .attr().

      [code]$(‘.myCheckbox’).attr(‘checked’, true);
      $(‘.myCheckbox’).attr(‘checked’, false);[/code]

      Note that this is the approach used by jQuery’s unit tests prior to version 1.6 and is preferable to using

      [code]$(‘.myCheckbox’).removeAttr(‘checked’);[/code]

      since the latter will, if the box was initially checked, change the behaviour of a call to .reset() on any form that contains it – a subtle but probably unwelcome behaviour change.

      For more context, some incomplete discussion of the changes to the handling of the checked attribute/property in the transition from 1.5.x to 1.6 can be found in the version 1.6 release notes and the Attributes vs. Properties section of the .prop() documentation.

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Adv 250x250

    Explore

    • Categories
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Dev Tools
      • Online Compiler
      • Base64 Converter
    • Wiki
      • SQL Tutorials
      • Java Tutorials
      • Python Tutorials
      • JavaScript Tutorials

    Footer

    Oraask

    About

    Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

    About Us

    • About Us
    • Contact Us

    Legal Stuff

    • Privacy Policy
    • Terms & Conditions

    Follow

    Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

    © 2019 Oraask. All Rights Reserved
    With Love by Oraask.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.