HTML 复选框可以设置为只读吗? [英] Can HTML checkboxes be set to readonly?

查看:24
本文介绍了HTML 复选框可以设置为只读吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为它们可能是,但由于我没有把钱放在嘴边(可以这么说),因此设置 readonly 属性实际上似乎没有任何作用.

I thought they could be, but as I'm not putting my money where my mouth was (so to speak) setting the readonly attribute doesn't actually seem to do anything.

我宁愿不使用禁用,因为我希望选中的复选框与表单的其余部分一起提交,我只是不希望客户在某些情况下能够更改它们.

I'd rather not use Disabled, since I want the checked check boxes to be submitted with the rest of the form, I just don't want the client to be able to change them under certain circumstances.

推荐答案

你可以使用这个:

<input type="checkbox" onclick="return false;"/>

这是有效的,因为从 click 事件返回 false 会停止执行链的继续.

This works because returning false from the click event stops the chain of execution continuing.

这篇关于HTML 复选框可以设置为只读吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆