In the Chrome DevTools, how can you know if a checkbox or radio button is checked. When you click on any of the above, the attribute checked
is not showing at all. It's annoying because I have to guess what's happening and it kind make development process slower. Is there some settings I need to apply?
A checkbox has two attributes that talk about it being checked: One is an HTML/DOM attribute, and one is a property of the scripting object. (dom-input-checked and attr-input-checked in the spec, respectively).
The spec sometimes uses the word reflect to indicate that these two kinds of attributes are kept in sync, but it does not in this case: The DOM attribute is the default checked state, and the IDL attribute is the current checked state. This allows to "Reset" a form, for instance.
Example of the attributes being different:
console.log([a.checked, a.getAttribute("checked")]);
a.checked = false;
console.log([a.checked, a.getAttribute("checked")]);
console.log([b.checked, b.getAttribute("checked")]);
b.checked = true;
console.log([b.checked, b.getAttribute("checked")]);
<input type=checkbox id=a checked>
<input type=checkbox id=b>
Anyway, you can use the "Properties" tab in Chrome's devtools to see the other attribute.
(In Firefox this is under Right click > Show DOM Properties, but you have to select the correct iframe first.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With