如何选择DOM元素中的动态跟随DOM元素?(CSS选择器) [英] How to select a dynamic following DOM element of a DOM element? (css selector)
本文介绍了如何选择DOM元素中的动态跟随DOM元素?(CSS选择器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
html:
<div>Hello</div
<my-custom-el>content</my-custom-el>
< my-custom-el>
可以是一次< my-custom-el>
,而其他时间< his-custom-el>
等...
The <my-custom-el>
can be once <my-custom-el>
, other time <his-custom-el>
etc...
是否有一种方法可以让CSS选择< div>
之后的元素,而又不知道DOM元素的类型是什么?
Is there a way to css select the element after the <div>
, without knowing what DOM element type will be?
推荐答案
是的,结合了相邻的同级(邻居")选择器 +
和通用选择器 *
:
Yeah, with the combination of adjacent sibling ("neighbor") selector +
and universal selector *
:
div + * { }
这将选择任何元素,这些元素立即紧随DOM中的任何 div
元素,其中立即意味着这两个元素必须具有相同的父元素元素.
This will select any element that immediately follows any div
element in the DOM, where immediately means that both elements must have the same parent element.
这篇关于如何选择DOM元素中的动态跟随DOM元素?(CSS选择器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文