Jquery: How to clear an element before appending new content?

前端 未结 4 1821
情话喂你
情话喂你 2020-12-30 19:34

This is my jquery code

 $.ajax({
   url: \"PopUpProductDetails.aspx\",
            cache: false
     }).done(function (html) {
     $(\"#dialog\").append(htm         


        
4条回答
  •  猫巷女王i
    2020-12-30 19:55

    You can use .empty() first, then use .append() in one line :)

    like this:

    $.ajax({
      url: "PopUpProductDetails.aspx",
            cache: false
        }).done(function (html) {
        $("#dialog").empty().append(html);
    });
    

提交回复
热议问题