Here is my javascript example code using jquery
$(".class").append("<a class='button-link' onclick='myFunction('"+ p1 +"' , '" + p2 + "')'>Click Me</a>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
The result in HTML is like this
<a class="button-link" onclick="myFunction("p1' , 'p2')'></a>
But I want the result is like this
<a class="button-link" onclick="myFunction('p1' , 'p2')"></a>
$(".class").append("<a class='button-link' onclick=\"myFunction('"+ p1 +"' , '" + p2 + "')\">Click Me</a>");