小编典典

HTML到使用JavaScript的XML转换?

json

是否可以使用JavaScript将所有div子级信息转换为XML或JSON?

$("#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("");
    }
  });

阅读 231

收藏
2020-07-27

共1个答案

小编典典

有一个名为externalHTML的属性。它设置或检索HTML中的对象及其内容。您可以按以下方式使用它。例如:

$(document).ready(function() {  
    $('#p').click(function() {
        alert($('#p')[0].outerHTML);
    }); 
});

提示:p是页面正文中的任何标签ID。

2020-07-27