使用javascript进行HTML转换为xml? [英] html to xml conversion using javascript?
本文介绍了使用javascript进行HTML转换为xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用JavaScript将所有div子信息转换为XML或JSON?
Is it possible to convert all div child information into XML or JSON using JavaScript?
$("#droppable").droppable({
drop : function(event, ui) {
var id = $(ui.draggable).attr("id");
var cloneObj = $((ui.draggable).clone());
$(cloneObj).removeClass("draggable ui-draggable");
if (id === "txt") {
inputOBj = document.createElement("input");
inputOBj.setAttribute("id", "txt" + i);
$("#droppable").append(inputOBj);
} else if (id == "combo") {
inputOBj = document.createElement("select");
inputOBj.setAttribute("id", "select" + i);
console.log("");
}
});
推荐答案
有一个名为outerHTML的属性。
它以HTML格式设置或检索对象及其内容。
你可以按照以下方式使用它。
例如:
there is property called outerHTML. It Sets or retrieves the object and its content in HTML. U can use it in following way. e.g:
$(document).ready(function() {
$('#p').click(function() {
alert($('#p')[0].outerHTML);
});
});
提示:p是您页面正文中的任何标签ID。
tip: p is your any tag ID in body of page.
这篇关于使用javascript进行HTML转换为xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文