1

I have code

<div>
    <a href="#"></a> »
    <a href="#"></a> »
    <a href="#"></a> »
    <a href="#"></a> »
    <a href="#"></a>
</div>

How i can disable or delete this simbol - "»" ?

I use this code

text = $('div').html();
text = text.replace('»','');
$('div').html(text);

but hi does not wokr correctly. The last symbol is displaing.

Another way?

Adrift
  • 55,121
  • 12
  • 89
  • 88
john
  • 65
  • 1
  • 3
  • 1
    possible duplicate of [jQuery - replace all instances of a character in a string](http://stackoverflow.com/questions/13574980/jquery-replace-all-instances-of-a-character-in-a-string) – Ram Oct 14 '14 at 21:17

2 Answers2

2

You just need to add the global flag (g) to your replace code like it was a regex:

text = $('div').html();
text = text.replace(/»/g,'');
$('div').html(text);

jsFiddle example

j08691
  • 197,815
  • 30
  • 248
  • 265
2

replace when passed a string only replaces the first instance. You must use a regular expression instead.

http://jsfiddle.net/zkvss6uf/

text = $('div').html();
text = text.replace(/»/g,'');
$('div').html(text);
Jason
  • 4,041
  • 4
  • 20
  • 30