javascript - 如何选择父级具有特定类的所有子级旁边的所有元素?
问题描述
我正在尝试选择不在 print 类中的所有元素。我想要一个真正选择每个元素的选择。(没有继承)。我怎样才能做到这一点?Javascript也很好。
所以3, 4, 5不应该是红色的。
body *:not(.print) {
color: red;
}
<div>
<!--this one-->
1
<!--this one-->
<p>2</p>
<!--this one-->
</div>
<div>
<div class="print">
3
<p>4</p>
<div>
<p>5</p>
</div>
</div>
</div>
<div>
<!--this one-->
6
<p>7</p>
<!--this one-->
</div>
解决方案
更新:
尝试这个:
html {
color: red;
}
.print, .print * {
color: black;
}
推荐阅读
- php - 在年份之间移动时如何正确处理 PHP DateTime 对象问题
- jenkins - 如何在 jenkins 中为 github webhook 设置 Secret
- android - Oppo 上显示 Qwerty 键盘,但它应该是数字键盘
- json - JSONField 在 JSON 中引用像一对一这样的模型
- angular - 量角器测试挂起等待 browser.wait 并禁用控制流
- python - 用最后一个不为零的值替换零
- selenium - UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败
- c# - Microsoft 服务总线 - 使用 OnMessage() 方法从总线接收消息
- java - 如何在数据库中删除或插入后触发 Jtable 更新?
- ios - 为什么 iOS 模拟器打印的是 $ 而不是 4?