CSS selector for quot;foo that contains barquot;?(“包含 bar 的 foo的 CSS 选择器?)
问题描述
有没有办法制作符合以下内容的 CSS 选择器?
Is there a way to make a CSS Selector that matches the following?
All OBJECT elements
which have a PARAM element inside of them
选择器
OBJECT PARAM
不起作用,因为它匹配 PARAM,而不是 OBJECT.我想将 { display:none } 应用于对象;将其应用于 PARAM 是没有用的.
doesn't work, as it matches the PARAM, not the OBJECT. I'd like to apply { display:none } to the objects; it's useless to apply that to the PARAMs.
(我知道我可以使用 jQuery - $("object param").closest("object")
- 和 VanillaJS - document.querySelector("objectparam").closest("object")
- 但我正在尝试在页面上创建 CSS 规则.)
(I'm aware I could pull this off with jQuery - $("object param").closest("object")
- and VanillaJS - document.querySelector("object param").closest("object")
- but I'm trying to create CSS rules on a page.)
推荐答案
不,您要查找的将称为 父选择器.CSS 没有;它们已被多次提出,但我不知道包括它们在内的现有或即将推出的标准.您是正确的,您需要使用 jQuery 之类的东西或使用额外的类注释来实现您想要的效果.
No, what you are looking for would be called a parent selector. CSS has none; they have been proposed multiple times but I know of no existing or forthcoming standard including them. You are correct that you would need to use something like jQuery or use additional class annotations to achieve the effect you want.
这里有一些类似的问题,结果相似:
Here are some similar questions with similar results:
- 是否有 CSS 父选择器?
- CSS 父/祖先选择器
- 活动子的父级的复杂 CSS 选择器
这篇关于“包含 bar 的 foo"的 CSS 选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“包含 bar 的 foo"的 CSS 选择器?


基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01