admin管理员组文章数量:1353137
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?
Example:
<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>
Please provide solution in JSFiddle, if possible. Thanks in advance!
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?
Example:
<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>
Please provide solution in JSFiddle, if possible. Thanks in advance!
Share Improve this question asked Mar 12, 2013 at 12:43 mknayabmknayab 3022 gold badges4 silver badges10 bronze badges3 Answers
Reset to default 6Find 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>'));
});
Example jsbin: http://jsbin./ogakit/1/
see the fiddle jsfiddle now its working
$(document).ready(function(){
$('p').each(function () {
var $this = $(this);
$this.html($this.text().replace(/\bquick\b/g, '<span style="display:none">quick</span>'));
});
});
I think this is what you want ..!!
<!DOCTYPE html>
<html>
<body id ="demo">
<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>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var str=document.getElementById("demo").innerHTML;
var n=str.replace("quick","HIDDEN");
document.getElementById("demo").innerHTML=n;
}
</script>
</body>
</html>
本文标签: javascriptHow to hide specific text from content wihtout calling any CSSStack Overflow
版权声明:本文标题:javascript - How to hide specific text from content wihtout calling any CSS? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743926053a2562979.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论