Questions tagged [checked]

The `checked` attribute of the HTML `input` tag used to set the checked state of the control to “on” by default. Used to set the state of the `input` controls with the `type` attribute `"checkbox"` or `"radio"`.

The checked attribute of the HTML input tag used to set the checked state of the control to “on” by default. Used to set the state of the input controls with the type attribute "checkbox" or "radio".

Used to present one or more checkboxes in such a way that the state of the control at the point of page load is checked, and the user has to opt out rather than opting in, or perhaps presenting the user with a form — including a series of checkboxes — that he or she has previously filled in, and preserve the state of the selections that were made. The checked attribute allows you to set the checked state to “on” by default.

The checked attribute is also used for radio input controls. Unlike the checkbox, only one in a range of related radio inputs can be selected, and the checked attribute is used to identify which one is selected. If you accidentally mark as "checked" a number of radio inputs that share a given name attribute, the last one that’s marked as such will be selected.

Details: http://reference.sitepoint.com/html/input/checked

813 questions
4554
votes
44 answers

Setting "checked" for a checkbox with jQuery

I'd like to do something like this to tick a checkbox using jQuery: $(".myCheckBox").checked(true); or $(".myCheckBox").selected(true); Does such a thing exist?
tpower
  • 56,100
  • 19
  • 68
  • 100
640
votes
18 answers

Find out whether radio button is checked with JQuery?

I can set a radio button to checked fine, but what I want to do is setup a sort of 'listener' that activates when a certain radio button is checked. Take, for example the following code: $("#element").click(function() { …
Keith Donegan
  • 26,213
  • 34
  • 94
  • 129
127
votes
11 answers

if checkbox is checked, do this

When I check a checkbox, I want it to turn

#0099ff. When I uncheck the checkbox, I want it to undo that. Code I have so far: $('#checkbox').click(function(){ if ($('#checkbox').attr('checked')) { /* NOT SURE WHAT TO DO HERE */ …

android.nick
  • 11,069
  • 23
  • 77
  • 112
126
votes
3 answers

What is the difference between the states selected, checked and activated in Android?

I'd like to know what differs those states. I didn't find any webpage clarifying this.
Louis
  • 2,140
  • 4
  • 19
  • 18
84
votes
9 answers

What is the proper way to check and uncheck a checkbox in HTML5?

Looked at the HTML spec, but couldn't make heads or tails of it: http://www.w3.org/TR/html5/the-input-element.html#attr-input-checked What is the correct way to check a checkbox in HTML (not dynamically)? checked="true" checked="checked" What is…
B Seven
  • 44,484
  • 66
  • 240
  • 385
62
votes
5 answers

How to count check-boxes using jQuery?

I have tons of checkboxes that are either checked (checked="checked") or unchecked. I would like to get the number of all checkboxes, unchecked and checked checkboxes. With check-box I mean . How can this be done with…
daGrevis
  • 21,014
  • 37
  • 100
  • 139
59
votes
1 answer

Jquery set radio button checked, using id and class selectors

Is it possible to set a radio button to checked using jquery - by a class and an id? For example: $('input:radio[class=test1 id=test2]).attr('checked', true); I only seem to be able to set it by id OR class but not by both.
Alan A
  • 2,557
  • 6
  • 32
  • 54
49
votes
3 answers

Why dividing int.MinValue by -1 threw OverflowException in unchecked context?

int y = -2147483648; int z = unchecked(y / -1); The second line causes an OverflowException. Shouldn't unchecked prevent this? For example: int y = -2147483648; int z = unchecked(y * 2); doesn't cause an exception.
48
votes
5 answers

How do I see which checkbox is checked?

How do I check in PHP whether a checkbox is checked or not?
Karem
  • 17,615
  • 72
  • 178
  • 278
35
votes
10 answers

Check first radio button with JQuery

I would like to check the first radio button of each group. But there are some radio button that are disabled, so the script should ignore them and go to next non-disabled button. I wrote something like this but it doesn't…
Matthew
  • 353
  • 1
  • 3
  • 4
35
votes
6 answers

Radio button checked event handling

In my application, I need a radio group, in which whenever a radio-button is checked, an alert occur so that I can post it's value to ajax post with jQuery. Can you help me please how i can do it in jQuery?
tarique
  • 2,201
  • 5
  • 19
  • 28
29
votes
2 answers

Change parent div on input[type=checkbox]:checked with css

I can figure out how to make the parent div change when checkbox is checked :( Changing the following paragraph works fine. Tried this approach without luck in Chrome: HTML ​
lajlev
  • 772
  • 2
  • 7
  • 22
26
votes
6 answers

Checkbox still checked hitting the back button, but it has no "checked" attribute

I am working on a checkbox-based filter for a e-commerce. Everything works fine but when I attempt to go back via the back button, the checkboxes still checked without any checked attribute. I noticed that this "issue" is occurring on…
Valérian Polizzi
  • 453
  • 1
  • 4
  • 10
26
votes
2 answers

jquery attr('checked','checked') works only once

I have a problem finding reason for the following jquery/checkbox behaviour. $( this.obj + ' table.sgrid-content > thead > tr > th > input.select_all' ).on( 'click' , {grid:this} , function(event){ var grid = event.data.grid; if(…
PiWo
  • 590
  • 2
  • 8
  • 17
25
votes
3 answers

C# checked block

Can someone explain to me what exactly is the checked an unchecked block ? And when should I use each ?
Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185
1
2 3
54 55