Home > Web Front-end > JS Tutorial > body text

A way to generate Html based on json string_javascript skills

WBOY
Release: 2016-05-16 17:44:00
Original
1386 people have browsed it
Article Description:
This article introduces a way to generate Html based on Json string (it only simply implements text boxes, password boxes, and drop-down boxes). I'm just doing this for fun. If you don't think it has any value, please ignore it. I hope you guys can point out the shortcomings and give me some advice. We will continue to improve it based on your guidance in the future.

Function Description:
A way to generate Html based on json string_javascript skills
Enter the Json string in the left input box. When you click to execute, the corresponding display will be displayed in the right display area based on the entered Json string. Html (using Jquery1.4.4)
HTML:
Copy code The code is as follows:












< ;td>




JS code:
Copy code The code is as follows:

$(document).ready(function () {
 $("#btnExec").click(function () {
try{
var objList = eval($("#txtJson"). val());
jsonToControl(objList);
}
catch(e){
alert("json format error");
}
});
});
function jsonToControl(jsonObj) {
$("#divShow").empty();
$.each(jsonObj, function (index, item) {
var control = null ;
var title = $("

Thank you very much for taking the time to read it. If you have any comments or suggestions, please leave a message.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Json input box
Display area