How to resolve < script > in < script type= "text/template" >. < / script >?

<script id="tpl" type="text/template">
<script>alert(1)</script>
</script>
<script>
console.log($("-sharptpl").html());
</script>

output : < script > alert (1)
how to solve this problem without ending < / script > ?

Mar.08,2021

looks like < script > of -sharptpl and < / script > after alert (1) , so the output is missing the ending < / script > .
and, from elements, you can clearly see that < / script > in the third line is ignored.

script nested script is useless, the browser does not recognize it correctly, and even if the browser does, it will not work.

for this question, please see the link , which is similar to yours.

Menu