如何用CSS隐藏HTML文档中的一个单词

时间:2014-03-27 02:39:50

标签: html css

我需要使用CSS隐藏HTML文档中所有出现的单词。这可能吗?

不包含标识符或类,html是web scraper操作的结果

例如

<tr class="">
    <th>EUROS BILLETE</th>
    <td>30.10</td>
    <td>31.99</td>
</tr>

在示例代码中,我需要隐藏的BILLET字,不是可以添加任何html标记,代码是来自web scraper动作的结果。

2 个答案:

答案 0 :(得分:3)

没有。在html / css中,您可以隐藏元素,而不是文本。您应该将单词包装在span等元素中并隐藏元素

<span class="text-to-hide">Whatever to text you want to hide</span>

span.text-to-hide
{
    display:none;
}

答案 1 :(得分:0)

<table>
<tr class="cell">
    <th class="hides">EUROS BILLETE</th>
    <td>30.10</td>
    <td>31.99</td>
</tr>
</table>

jquery的

   $(function() {


        // 
        //$('th:contains("EUROS BILLETE")').css('display', 'none');


        //or
        $('.hides').filter(function() {
        return $(this).html().indexOf('BILLETE') != -1;
       }).remove();

        var th=$('<th>' + "EUROS" + '</th>');
        $('.cell').append(th);
    });

CSS

 <p class="youclass">paragraph</p>

   .youclass{
    display: none;
    }

and mostrate

.youclass{
display: block;
}