简体   繁体   English

使用 css 隐藏特定 p 标签的第二个 div

[英]hide second div of a particular p tag using css

I want to hide the second div after this div, there is no identifier for that div .我想隐藏这个div之后的第二格,对于没有标识div

That's why I took this p tag attribute as an identifier.这就是我将这个p标签属性作为标识符的原因。 I tried using jQuery, but in page load it's sometimes visible.我尝试使用 jQuery,但在页面加载中它有时是可见的。 Is there any way to hide it permanently?有没有办法永久隐藏它?

div p[data-udy-fe="text_-a91032"] {
    
}

I'm adding my jQuery code here, but when page loading we can see the div 's content for some seconds.我在这里添加我的 jQuery 代码,但是当页面加载时,我们可以看到div的内容几秒钟。 I need to hide it permanently, without the brief flash.我需要永久隐藏它,没有短暂的闪光。

$("p").each(function(){        
    if($(this).attr('data-udy-fe') == 'text_-a91032') {
        $(this).next('div').next('div').hide();
    }
});

You can use + div + div selector您可以使用+ div + div选择器

 p[data-udy-fe="text_-a91032"]+ div + div { display: none; }
 <div> <div>Paragraph1</div> <div>Paragraph2</div> <p data-udy-fe="text_-a91032">Paragraph3</p> <div>Paragraph4</div> <div>this one is not displayed</div> <div>Paragraph6</div> <div>

You can use the general sibling combinator to select the p tag which occurs after your specific element.您可以使用通用同级组合器来选择出现在您的特定元素之后的 p 标签。

div p[data-udy-fe="text_-a91032"] ~ p {
     display: none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM