I am adding a script in html and within a string of the style. I do this because we show a piece of code on our platform that we want the user to be able to copy by clicking on a copy button:
<script>
function copyCode(){
$("body").append($temp);
$temp.val("<div id=\"1"></div>"+
"<script>(function(a,b,c) {
...
}("a", "b", "c"));
</"+"script>").select();
document.execCommand("copy");
$temp.remove();
}
</script>
The problem is that closing the script of the variable I created gives me an error (as if I assumed that the closing of the script inside the variable is the end of the script ...).
Do you know any way to solve it?
Currently the solution I have is this:
var text = '<script> ... </'+'script>';
Edit: I have added the code more fully as I have explained the problem better.