我使用的是elementor pro的portfolio小部件。作为标准,过滤器栏自带了一个过滤器,可以显示下面的所有卡片,现在我已经设法通过使用display none从前端删除了这个li。然而,该网站仍然展示了所有的卡片。我的想法是使用此代码来激活第二个列表项:
jQuery('.elementor-portfolio__filters li:nth-child(2)').addClass('elementor-active');
遗憾的是,这并没有奏效。我不确定是否有办法让这段代码运行并覆盖任何其他jQuery?
任何帮助都将不胜感激。
发布于 2021-10-07 16:28:41
它工作得很好,请检查您的html。
$('.myClass li:nth-child(2)').addClass('newClass');.newClass {
color: red;
}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='myClass'>
<ol>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ol>
</div>
https://stackoverflow.com/questions/69484593
复制相似问题