1
<div>
<p style="font-size=40px;">
<b>Hello there, welcome</b>
<br/>
To this website
</p>
<p>Some other text</p>

我如何只抓取第一个 p 标签内的文本(“到这个网站”)?我不能给它一个类或 ID,因为它是用 wordpress 中的视觉作曲家完成的,我也不能在 wordpress 中设置它的样式,但我只需要设置那部分的样式。

4

1 回答 1

3

也许是这样的?

http://codepen.io/anon/pen/YGpvxE

下面的片段示例

    p:first-child {
      color: red !important; /** Use important only in very rare situations **/
    }
    
    p b {
      color: initial;
    }
 <div>
    <p>
    <b>Hello there, welcome</b>
    <br/>
    To this website
    </p>
    <p>Some other text</p>
    </div>

编辑: 要覆盖您可以!important在 css 中使用的内联样式。

于 2016-09-21T08:57:01.830 回答