I want to get some textarea text and replace all bullet point html entities •
with ·
.
The usual approach str.replace(/•/g,"·");
doesn't work.
Any advice would be appreciated.
I want to get some textarea text and replace all bullet point html entities •
with ·
.
The usual approach str.replace(/•/g,"·");
doesn't work.
Any advice would be appreciated.
When you're getting the text value back from the textarea, it has already been converted to its actual character. To do a string replacement on that string, either
Here's an example of the second approach.
var newText = oldText.replace(/•/g, "");
You can fiddle with an example here.
If you want to go with the first approach, see this question and its answers for ways to convert characters in a piece of text to their corresponding html entities.
If you want to do this without jQuery:
var myTextarea = document.getElementById('id_of_your_textarea');
myTextarea.value = myTextarea.value.replace(/•/g, '·');
jQuery:
$("#myTextarea").val( $("#myTextarea").val().replace(/•/g, '·') );
.val()
will get the value from an input element, .val('str')
will set a value.