MathQuill is a formula editor for web applications. I started using MathQuill in my math-problem generator to dynamically generate math problems . In order to use MathQuill, add the following between the <head> tags of your HTML:

<link rel="stylesheet" href="css/mathquill.css"/>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/mathquill.js"></script>

At the end of the <html> document, add the following:

    var MQ = MathQuill.getInterface(2); // for backward compatibility

Now you can use the following Javascript code to dynamically generate math statements for <span id=”id”></span> with the corresponding ID:

function name() {
    var span1 = document.getElementById("id");
    span1.innerHTML = "";