Do it like this:
(像这样做:)
var value = $("#text").val(); // value = 9.61 use $("#text").text() if you are not on select box...
value = value.replace(".", ":"); // value = 9:61
// can then use it as
$("#anothertext").val(value);
Updated to reflect to current version of jQuery.
(更新以反映当前版本的jQuery。)
And also there are a lot of answers here that would best fit to any same situation as this.(而且这里有很多答案最适合这种情况。)
You, as a developer, need to know which is which.(作为开发人员,您需要知道哪个是哪个。)
Replace all occurrences(替换所有出现的事件)
To replace multiple characters at a time use some thing like this: name.replace(/&/g, "-")
.
(要一次替换多个字符,请使用以下命令: name.replace(/&/g, "-")
。)
Here I am replacing all &
chars with -
.(在这里,我用-
替换所有&
字符。)
g
means "global"(g
表示“全球”)
Note - you may need to add square brackets to avoid an error - title.replace(/[+]/g, " ")
(注意 - 您可能需要添加方括号以避免错误 - title.replace(/[+]/g, " ")
)
credits vissu and Dante Cullari
(信用vissu和Dante Cullari)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…