JSFiddle - React, Tailwind, and code Playground
HTML
<div style="background:red">
aaa
<span>sometext</span>
</div>
<a class="remote" href="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">click me</a>
JavaScript
$(function() {
$("a.remote").live("click", function(e) {
$.ajax({
url: this.href,
dataType: "script",
success: function(xhr, status) {
myFunction();
}
});
e.preventDefault();
return false;
});
});
function myFunction() {
//$("span").each(function(){
// $(this).text($(this).text().replace("some", "more"));
//});
$("span").replaceWith("<p>test</p>");
}