jQuery Hide part of a string based on text -


if have html like:

<div class="text">good stuff hide me</div> <div class="text">great stuff hide me</div> <div class="text">best stuff hide me</div> 

and want hide "hide me" in every instance of div.text you're left with

good stuff
great stuff
best stuff

how jquery?

this $("div:contains('hide me')").hide(); hides entire string. how can isolate text want hide?

if want remove text, use:

$('div.text').text(function (i, t) {     return t.replace(' hide me', ''); }) 

jsfiddle example

to hide it, use:

$('div.text').html(function (i, t) {     return t.replace('hide me', '<span class="hidden">hide me</span>'); }) 

with css .hidden { display:none; }

jsfiddle example


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -