CSSでは、
特定のプロパティを持つ要素の後に別のプロパティを持つ要素を一致させることは可能ですか?
考えてみましょう
<div my-custom-attribute="0">
</div>
<div my-custom-attribute="1">
</div>
my-custom-attributeが0に等しいすべての要素を選択し、その後にmy-custom-attributeが1に等しい要素が続きます。
CSSでは、
特定のプロパティを持つ要素の後に別のプロパティを持つ要素を一致させることは可能ですか?
考えてみましょう
<div my-custom-attribute="0">
</div>
<div my-custom-attribute="1">
</div>
my-custom-attributeが0に等しいすべての要素を選択し、その後にmy-custom-attributeが1に等しい要素が続きます。
これは、属性セレクターを使用して逆の順序で行うことができます
div[my-custom-attribute="0"] > div[my-custom-attribute="1"]
また
<div id="parent">
<div my-custom-attribute="0">
</div>
<div my-custom-attribute="1">
</div>
</div>
#parent > div[my-custom-attribute]:not(:first-child)
ご回答ありがとうございます。CSSの代わりにjQueryセレクターを使用することになりました。
私の場合、jQueryprev()
は機能しました
$($('div[my-custom-attribute="1"]').prev('div[my-custom-attribute="0"]'))