Replacing a character on a page with jQuery
I have this:
<h1><b>Headline:</b> something</h1>
and I want to get rid of the colon (:) on the page.
What's the easiest way to do it with jQuery? I'm a JS ne开发者_如何转开发wbie so please provide the entire code what I need to insert in the head-tag.
Thanks!
Replacing :
if it is last character in <b>
:
$('h1 b').text(function(i, t) {
return t.replace(/:$/, '');
});
(demo)
You could use the :contains
selector:
var b = $('b:contains(\:)');
b.html(b.html().replace('\:', ''));
Demo.
You can do this
$('h1 b').html().replace(':','');
精彩评论