Deb*_*iti 2 html javascript tags html5
有什么方法可以用来显示[在html中]涉及脚本标记的代码段,同时阻止浏览器执行该脚本代码?
编码所有<和>字符,所以你最终得到
<div>
<h2>Here's some JS code</h2>
<pre>
<script type="text/javascript">
var x = 7;
var y = 10;
if (x < y) {
alert('this alert will not fire!');
}
</script>
</pre>
</div>
Run Code Online (Sandbox Code Playgroud)