我想让 DIV 中的内容不可编辑但仍可查看。
<div id="committee"><?php include 'committee_members_list.php'; ?></div>
DIV 在其中保存“包含”文件的内容。我希望内容可见但不可编辑或不可点击。
DIV 的内容如上所示。
注意:text 和 textarea 元素不在 DIV 中的包含文件中
DIV 中的所有内容都应该按原样显示,但没有任何内容应该是可点击/可编辑的。我怎样才能实现/实现这个?
最佳答案
div 通常是不可编辑的。如果你想要一个不可编辑的文本框,添加“只读”:
<input type="textbox" name="test" readonly>
编辑:或者您可以通过具有用户选择属性的 CSS 阻止它:
.unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
请记住,这不是验证,我可以使用 firebug 或类似工具修改其中的内容。
关于javascript - 使DIV中的内容不可编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21114077/