我见过许多声明脚本标签的不同方式。其中一些是:
变体 1:
<script type="text/javascript">
//some javascript here
</script>
变体 2:
<script type="text/javascript">
//<![CDATA[
// some javascript here
//]]>
</script>
变体 3:
<script language="javascript">
//some javascript here
</script>
变体 4:
<script>
//some javascript here
</script>
还有其他变体。当我们在 HTML5 + js 中工作时,哪种方式更适合声明 Script 标签?
最佳答案
在 HTML5 中,您不需要像“类型”这样的附加属性。只需使用 <script></script>
声明 JavaScript 代码.
关于javascript - 在 HTML5 中声明脚本标签的最佳方式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20947518/