这个怎么样?
http://jsfiddle.net/mWuHe/14/
提取您所在区域的HTML,然后将其转换回JSON:
$(':button').click(function() { $('#output').text(JSON.stringify({ data:$('#input').html() }));});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div id="input" contenteditable="true" ><b>Edit me!</b> You can use CTRL+B to change bold, ctrl+I to change italics.</div><div > <input type="button" value="Get HTML"></div><div id="output" ></div>顺便说一句,我
JSON.stringify只是为了简单起见,但是在生产环境中,您可能应该使用jquery-
json之类的库,因为某些不支持的旧浏览器仍然在运行。



