简体   繁体   English

复选框选中的属性在Chrome或Firefox开发者工具中不会更改

[英]Check box checked property doesn't change in Chrome or Firefox Developer Tools

Suppose you have a check box, which is checked. 假设您有一个复选框,该复选框已选中。 In Chrome or Firefox, when you click inspect element, in the HTML you will see: 在Chrome或Firefox中,单击inspect元素时,在HTML中您会看到:

<input checked="checked" class="some-class" id="some-id" name="some-name" type="checkbox" value="some-value">

I expect, that when I click on the check box and uncheck it, the html will change and the checked property will disappear: 我希望,当我单击复选框并取消选中它时,html将更改,并且checked属性将消失:

<input class="some-class" id="some-id" name="some-name" type="checkbox" value="some-value">

However, that's not the case. 但事实并非如此。 Why? 为什么?

That is just the default property defined by the HTML attribute of the element when loaded. 这只是加载时元素的HTML attribute定义的默认属性。 When unchecked, its the DOM property that is whats actually toggled. 取消选中时,它的DOM property实际上是切换的。 Which is why the attribute does not seem to change. 这就是属性似乎没有改变的原因。

This follow code outputs the current DOM checked property to the console: 此跟随代码将当前DOM checked属性输出到控制台:

$("input").click(function(){
    console.log($(this)[0].checked);
});

Here is the JSFiddle 这是JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Chrome 开发者工具橙色框 - Chrome Developer tools orange box 为什么切换在 Firefox 开发人员工具上不起作用? - Why toggling doesn't work on Firefox Developer Tools? Firefox文档检查器,Firebug和Webkit开发人员工具(Chrome / Safari)无法更新HTML以反映通过AJAX加载的复选框的选中状态 - Firefox Document Inspector, Firebug & Webkit Developer Tools (Chrome/Safari) not updating HTML to reflect checked status of checkboxes loaded via AJAX 链接在Chrome和Firefox中不可点击,直到打开开发人员工具 - Links un-clickable in Chrome & Firefox until developer tools are opened 为什么我的网格在 Chrome 中不起作用,但在 Firefox Developer Edition 中起作用? - Why my grid doesn't work in Chrome but, does in Firefox Developer Edition? chrome开发人员工具中的图标 - Icons in chrome developer tools 如何使用 Chrome 开发人员工具检查有效的 CSS 连字符? - How to check the CSS hyphens in effect using Chrome developer tools? Chrome开发者工具-是否可以检查当前文件名? - Chrome developer tools - is there a way to check current's file name? 从javascript设置选中的属性时,复选框更改事件未触发 - check box change event not firing when checked property set from javascript 如何更改已禁用复选框的选中颜色 - How to change checked color of disabled check box
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM