如何影响 jQuery 中具有特定后代的祖先?
我有这两个具有相同类名 () 的 DIV:
<div class="myOutterDiv">
<ul class="innerUL">
<li id="num1">1</li>
<li id="num2">2</li>
</ul>
</div>
<div class="myOutterDiv">
<ul class="innerUL2">
<li id="letterA">A</li>
<li id="letterB">B</li>
</ul>
</div>
我想将带有蓝色边框的 css 边框应用于包含 2 的边框,将红色边框应用于包含 B 的边框。
我尝试过使用parentsUntil (),但对 class="myOutterDiv" 之前的所有祖先应用了边框。我只想影响 class="myOutterDiv"。
谢谢!
I've got these two DIVs which have the same class name ():
<div class="myOutterDiv">
<ul class="innerUL">
<li id="num1">1</li>
<li id="num2">2</li>
</ul>
</div>
<div class="myOutterDiv">
<ul class="innerUL2">
<li id="letterA">A</li>
<li id="letterB">B</li>
</ul>
</div>
I'd like to apply a css border with a blue color to the one that contains 2
and red to the one that contains B
.
I've tried using parentsUntil(), but applied a border to all the ancestors up to class="myOutterDiv". I just want to affect class="myOutterDiv".
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对你有用吗?
Would this work for you?
怎么样:
What about: