jquery - 当文本框内容可编辑为假时如何更改文本颜色?
问题描述
内容可编辑真/假时如何更改样式?当可编辑为真时需要红色,当它为假时需要灰色。这在 CSS 中可能吗?
这是我的html代码:
<body spellcheck="false" autocorrect="off" contenteditable="false" style="color:gray;>
Need to change color of the text when it is false
</body>
解决方案
使用 css选择器,attribute
这里是关于 css 中选择器的教程:https ://www.w3schools.com/cssref/css_selectors.asp
body[contenteditable="true"]{
color:red;
}
body[contenteditable="false"]{
color:grey;
}
推荐阅读
- file - Perl 哈希:使用来自外部文本文件的键/值对
- c++ - 如何在 C++ 中解决网格继承问题
- assembly - 试图将寄存器设置为负值会导致 SEGFAULT
- wordpress - 如何通过表单验证从前端表单提交创建 woocommerce 产品
- java - 无法通过从 JsonObject 获取值来编译代码
- r - 是否可以将 summarise 与 summarise_at 与 dplyr 结合在一个 group_by 中
- java - Docker:未安装 Oracle JDK 8
- spring-batch - 使 Spring Batch ItemReader 可重新启动
- php - 我正在尝试检查我的编辑视图上的所有复选框,以从表中获取数据
- components - ExpressionChangedAfterItHasBeenCheckedError 一个路由两个组件