gpt4 book ai didi

html - 选择包含特定 id 的上一个 div

转载 作者:太空狗 更新时间:2023-10-29 12:35:35 26 4
gpt4 key购买 nike

我正在使用 joomla,我有如下 html

<div id="ja-footerwrap">
<div class="moduletable">
<div id="bottom-slider">
<!--some contents-->
</div>
</div>
<div class="moduletable">
<div id="bottom-slider">
<!--some contents-->
</div>
</div>
<div class="moduletable">

<!--some contents-->

</div>
<!--and other divs with classes moduletable------>
</div>

我必须选择 moduletable 并且必须将 display: inline-block; 仅应用于包含 bottom-slider id 的那个 div。我该怎么做?

最佳答案

首先,您不能拥有多个具有相同 ID 的 DOM 对象,那么第一件事就是更改标记并将 id="bottom-slider" 转换为 class="bottom- slider ”

然后您可以使用 jQuery 更改带有类 moduletable bottom-slider childrens 的父 div:

$('.bottom-slider').parent('.moduletable').css({'display':'inline-block'});

这里是 fiddle :http://jsfiddle.net/9tvcf/

希望对你有帮助

关于html - 选择包含特定 id 的上一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17874742/

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