简体   繁体   English

如何在JavaScript中更改字符串中的单个字符

[英]How to change single char from string in JavaScript

I have a variable which contains the following string 我有一个包含以下字符串的变量

placeholder = "<strong>Total Damage:</strong> $70,000.00"

Now, I am trying to replace Dollor sign($) with pound sign(£). 现在,我正在尝试用英镑符号(£)替换Dollor标志($)。 Any idea how this can be done? 知道如何做到这一点?

[Edit] [编辑]

I don't know javascript, still trying to learn. 我不知道javascript,还在努力学习。 now the solution seems so simple, I feel embarrassed now. 现在解决方案似乎很简单,我现在感到尴尬。 Sorry for bothering everyone with such silly question :( 抱歉打扰每个人这样愚蠢的问题:(

placeholder = placeholder.replace("$","£");

Simples!

Really? 真?

JavaScript Replace JavaScript替换

var myNewString = myOldString.replace("something", "new thing"); var myNewString = myOldString.replace(“something”,“new thing”);

placeholder = "<strong>Total Damage:</strong> $70,000.00".replace("$","£");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM