javascript - 使DIV中的内容不可编辑

标签 javascript php html php-include

我想让 DIV 中的内容不可编辑但仍可查看。

<div id="committee"><?php include 'committee_members_list.php'; ?></div>

DIV 在其中保存“包含”文件的内容。我希望内容可见但不可编辑或不可点击。

enter image description here 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/

相关文章:

phpmyadmin 自动注销时间

php - 如何从数据库适配器获取 MySQL 中最后生成的错误

javascript - 编辑特定网站上的 url

javascript - Html5 - Javascript - 内联网的 sqlite?

javascript - Google 跟踪代码管理器中回调函数的 AdWords 转化跟踪

javascript - 如何更改相对于另一个下拉列表的下拉列表

javascript - 在 JavaScript 中用换行符替换空格?

javascript - Web Audio Api - 下载编辑后的 ​​MP3

php - 将字符串分隔成数组

javascript - 将文本标签和/或图标附加到 div