Can someone tell me why this is not working, and the variable still holds the string with the ":" in it?
btn_id_postfix = "hehe:haha";
btn_id_postfix.replace(/\:/g,"");
Can someone tell me why this is not working, and the variable still holds the string with the ":" in it?
btn_id_postfix = "hehe:haha";
btn_id_postfix.replace(/\:/g,"");
btn_id_postfix=btn_id_postfix.replace(/\:/g,"");
replace returns value, but doesn't change string.
replace doesn't change the value of the string you're modifying. What you have to do is simply to assign it to the variable.
btn_id_postfix = "hehe:haha";
btn_id_postfix = btn_id_postfix.replace(/\:/g,"");
You're not assigning the result to a variable. Try this:
btn_id_postfix = "hehe:haha";
btn_id_postfix = btn_id_postfix.replace(/\:/g,"");