JSFiddle - React, Tailwind, and code Playground

by fguillen

HTML

<div id="divToUpdate">
    Old Content
</div>
<button id="testButton">test me</button>

CSS

#divToUpdate {
    display:none;
}

#divReceived {
    background-color: yellow;
}

JavaScript

$("#testButton").click(function() {
  $.ajax({
    url: '/echo/html/',
    data: {
        html: "<div id=\"divReceived\">This is the new content</div>",
        delay: 1
    },
    method: "post",
    dataType: "html",
    success: function (data) {
      $("#divToUpdate").html(data);
      $("#divToUpdate").css({"display": "block"});
    }
  });
});