开发者

string replace javascript/jquery

开发者 https://www.devze.com 2023-02-22 01:57 出处:网络
[{\"fi开发者_运维问答eld\":\"Comment\",\"message\":\"Message cannot be empty\"}] In the above string i want to replace the word comment. I dont wish to use any other external libraries expect jquery
[{"fi开发者_运维问答eld":"Comment","message":"Message cannot be empty"}]

In the above string i want to replace the word comment. I dont wish to use any other external libraries expect jquery


Suppose you're talking about array object:

var array = [{"field":"Comment","message":"Message cannot be empty"}];

Then what you need is:

array[0]["field"] = "other value comes here";

Live test case: http://jsfiddle.net/yahavbr/7Xgwk/
(Click "View", click "Change" and click "View" again)


javaScript replace() Method

Example code :

<script type="text/javascript">

var str="Visit Microsoft!";
document.write(str.replace(/microsoft/i, "W3Schools"));

</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消