Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

html - HTML复选框可以设置为只读吗?(Can HTML checkboxes be set to 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.

(我以为他们可以,但是因为我不把钱放在我的嘴里(可以这么说)设置readonly属性实际上似乎没有做任何事情。)

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.

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

  ask by community wiki translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you can use this:

(你可以用这个:)

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...