<html>
<head>
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("<span><b>Hello world!</b></span>").replaceAll("p:last");
});
});
</script>
</head>
<body>
<button>Replace the last p element with a span element</button><br>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>