gpt4 book ai didi

jquery - 李 :nth-child(odd) doesn't work after adding a

转载 作者:太空宇宙 更新时间:2023-11-03 23:53:17 25 4
gpt4 key购买 nike

我确实有一个元素列表,在 jQuery 的帮助下可以使用不同的颜色:

$('ul.follows li:nth-child(odd)').addClass('alternate');

在我添加 a 之前一切正常列表项前的标记。所以...现在我有:

    <ul class="follows">
<a href="#">
<li class="me">
<img src="#">
<h3>#</h3>
<p>#</p>
</li>
</a>
...</ul>

知道为什么它不再起作用了吗?

我可以得到 <a><li>里面但是我不确定整个元素是如何被点击的……

最佳答案

修复您的列表标记(UL 的唯一有效子项是 LI),然后执行此操作:

ul.follows li {padding: 0;}
ul.follows li a {display: block; height: 100%;}

您的 jQuery 现在应该可以工作了,您的 LI 将在整个宽度上都可以点击。

http://jsfiddle.net/isherwood/5ctc3/

关于jquery - 李 :nth-child(odd) doesn't work after adding a,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19367649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com