我想将部分html代码保存为json作为文件,然后重新记录html代码进行编辑.知道我该怎么办?
<div id='TextBoxesGroup'>
<div id="TextBoxDiv1">
<label class="draggable ui-widget-content clickableLabel" id="label1" >New Text</label>
<input id='textbox1' class="clickedit" type="text" class="draggable" class="ui-widget-content" placeholder="Text Here"/>
<div class="clearfix"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我是json的新手,请尽可能简化.我看过其他问题,但他们似乎没有解决我的问题
HTML:
<input name="fileToUpload" type="file" id="fileToUpload"/>
<div id="div1"> </div>
Run Code Online (Sandbox Code Playgroud)
查询:
$(function()
{
$("#fileToUpload").on('change', 'input' , function(){
// Display image on the page for viewing
readURL(this,"div1");
});
});
function readURL(input , tar) {
if (input.files && input.files[0]) { // got sth
// Clear image container
$("#" + tar ).empty();
$.each(input.files , function(index,ff) // loop each image
{
var reader = new FileReader();
// Put image in created image tags
reader.onload = function (e) {
$('#' + tar).attr('src', e.target.result);
}
reader.readAsDataURL(ff);
});
} …Run Code Online (Sandbox Code Playgroud)