Change format of a specific word using CSS

后端 未结 1 711
忘了有多久
忘了有多久 2021-01-26 20:35

Text can come form different source. After getting text it will display on site. From this text I need to change format of a specific word using CSS. In following example

相关标签:
1条回答
  • 2021-01-26 20:44

    You cannot select content with CSS, but with jQuery you can. You could wrap "database" in span and then use CSS to style it. For example:

    HTML:

    <p>A <span class="database">database</span> is a collection of information. In one view <span class="database">database</span> can be classified.</p>
    

    CSS:

    .database {color: red;}
    

    When it comes to jQuery:

    $( "p:contains('database')" ).css( "color", "red" );
    

    That would probably be the easiest solution, but I personally don't like it.

    0 讨论(0)
提交回复
热议问题