Sign Up

Sign Up to our social questions and Answers Engine 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 Engine 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

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8057213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:57:18+00:00 2026-06-05T08:57:18+00:00

I want to get checkbox with specfic value and make it checked.. I make

  • 0

I want to get checkbox with specfic value and make it checked..

I make like this

$(":checkbox").filter({"value":5}).attr("checked","true");​

and here is the html

​<input type="checkbox" name="priv"​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ value="1"​​​​​​​​​​​​​​​​​/>
<input type="checkbox" name="priv" value="2"/>
<input type="checkbox" name="priv" value="3"/>
<input type="checkbox" name="priv" value="4"/>
<input type="checkbox" name="priv" value="5"/>
<input type="checkbox" name="priv" value="6"/>
<input type="checkbox" name="priv" value="7"/>
 <input type="checkbox" name="priv" value="8"/>​

here’s a demo of the problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:57:19+00:00Added an answer on June 5, 2026 at 8:57 am

    You can use Attribute Equals Selector [name=”value”] to get the checkboxes with particular value. Also use prop() instead of attr() as that is recommended way by jQuery doc.

    Live Demo

    $(":checkbox[value=4]").prop("checked","true");
    

    or

    $("input[type=checkbox][value=5]").prop("checked",true);
    

    Description: Selects elements that have the specified attribute with a value exactly equal to a certain value, jQuery doc.

    You can also do it Using attr() but prop is more appropriate for boolean properties.

    $(":checkbox[value=4]").attr("checked","true");
    

    As of jQuery 1.6, the .attr() method returns undefined for attributes
    that have not been set. To retrieve and change DOM properties such as
    the checked, selected, or disabled state of form elements, use the
    .prop() method, jQuery doc

    Edit, asked in comments, “How would look like the answer/find-expression with complex values, like value=”Smith, David“

    You can enclose that kind of values like Smith, David on single quotes. You can even use character used by jQuery like #, ., $ etc, see updated fiddle here.

    $("input[type=checkbox][value='#Smith, David$']").attr("checked","true");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to get/change value of CheckBox with JavaScript. Not that I cannot
I have following html control in view: <%= Html.CheckBox(MyStatus, (item.MyStatus>0)?true:false)%> Then I want to
am having a set of checkbox in a stackpanel, i want to get the
I want get the return value class of an instance in runtime. The thing
i want get weather from http://www.google.com/ig/api?weather= I use this // load xml result from
I have a check box and want to get the very inital value or
I want to get the id value of c_i . And each time c_i
i want to get the selected item values from listfield checkbox when clicking on
I want to get the value of the check box in the result variable.
i want an alarm to go off when user checks in a checkbox. Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.