如何隐藏特定的文本从内容wihtout调用任何CSS? [英] How to hide specific text from content wihtout calling any CSS?
问题描述
我需要从下面的内容中只隐藏字词QUICK,无需调用任何类或标记中的更改。在纯CSS中是不可能的,可能我们可以做这个JavaScript / jQuery,并调用QUICK作为一个变量,并使用CSS隐藏。我不是很好的Java编码,所以可以任何人帮助这个周围吗?
I need to hide only word "QUICK" from the content below without calling any class or changes in Markup. It is not possible in pure CSS, probably we can do this JavaScript / jQuery and call QUICK as a variable and use CSS to hide. I am not good in Java coding so can anyone help this around?
例如:
<html>
<p>The quick brown fox jump over the lazy dog.</p>
<p>The quick brown fox is too hungry.</p>
<p>The poor quick brown fox is tired and thirsty.</p>
</html>
如果可能,请提供JSFiddle的解决方案。提前感谢!
Please provide solution in JSFiddle, if possible. Thanks in advance!
推荐答案
查找 quick
的所有出现intp通过css隐藏的特定元素(例如< del>
)
Find all occurences of quick
and wrap them intp a specific element (e.g. <del>
) hidden via css
CSS
p del {
display: none;
}
jQuery
$('p').each(function() {
var $this = $(this);
$this.html($this.text().replace(/\bquick\b/g, '<del>quick</del>'));
});
示例jsbin: http://jsbin.com/ogakit/1/
这篇关于如何隐藏特定的文本从内容wihtout调用任何CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!