是否有可能使用JavaScript將所有div子信息轉換爲XML或JSON?html to xml轉換使用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("");
}
});
從我所瞭解的html和xml密切相關。你想從另一個轉換爲一個特定的原因? – Neeraj
感謝您的回覆。 我想用javascrip中的Drag -n-Drop生成html代碼。 我能夠在DnD中創建hmtl表單,但要保存到單獨的文件 我需要xml/json或任何可以用來將生成的代碼保存到單獨文件中的任何文件。 –
這個答案可能會幫助 http://stackoverflow.com/questions/10866997/js-jquery-other-library-plugin-to-convert-html-xml – Neeraj