Home  >  Article  >  Web Front-end  >  基于javascript的JSON格式页面展示美化方法_javascript技巧

基于javascript的JSON格式页面展示美化方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 16:42:411204browse
{"name": "monkey","age": "24","height": 164.0}

如果想让以上json字符串在页面上展示的比较易读,即变成下面的style:

{ 
"name": "monkey", 
"age": "24", 
"height": 164.0cm 
}

本文介绍的方法基于javascript ,代码如下:

 
/ 
//style中是css代码 
   
//script中是javascript代码 
 

 //表示页面加载时调用myFunction()

其中window.error_id_msgs是所要转换的json对象,css和myFunction结合可实现页面展示转换

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn