Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  153] [ 2]  / answers: 1 / hits: 76326  / 11 Years ago, mon, april 15, 2013, 12:00:00

I am trying to replace within a string using jquery



var myString =qwerty

var avoid =t


I want to do someting like



myString.replace(avoid,'');


I was able to remove like myString.replace('t',''); But i want it to be like myString.replace(avoid,'');



How to do it?



JsFiddle : http://jsfiddle.net/nKSZT/


More From » jquery

 Answers
11

Your problem is that replace does not replace the characters in your original string but returns a new string with the replacement.



myString = myString.replace(avoid,'');

[#78906] Saturday, April 13, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidan

Total Points: 72
Total Questions: 95
Total Answers: 121

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
aidan questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Sep 29, 21, 00:00, 3 Years ago
Sun, Sep 5, 21, 00:00, 3 Years ago
Thu, Jan 16, 20, 00:00, 4 Years ago
;