1

I want to replace the word "residue1" to "calcule" in jquery or javascript but the actual word was "residue11" .

I user this function but it's not effective

 var calculeId = residueId.replace('residue1', 'calcule');
3
  • it works jsfiddle.net/achakravarty/zEAW5 Commented Aug 30, 2013 at 4:48
  • Whats wrong in using str.replace()? Commented Aug 30, 2013 at 4:48
  • Sorry, could you clarify this? Do you mean you used the above code and it replaced "residue11" when you only wanted it to replace "residue1"? Commented Aug 30, 2013 at 4:48

5 Answers 5

1

It will be like

var residueId = "residue11";
var calculeId = residueId.replace('residue1', 'calcule');
alert(calculeId);
Sign up to request clarification or add additional context in comments.

Comments

0

use in javascript like this

var str="residue11";
var n=str.replace("residue1","calcule"); 

Comments

0

try

var calculeId = 'residue11'.replace('residue1', 'calcule');

Comments

0
var str="residue11";

var n=str.replace(/residue1/g,"calcule"); 

Comments

0

Do you mean this?

var residueId = 'residue11'
alert(residueId.replace(/residue1|residue11/, 'calcule'))

Example - jsfiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.