【发布时间】:2016-07-13 17:08:52
【问题描述】:
我一直在使用诸如引导模板之类的模板,当我尝试修改或添加更多脚本时,我总是遇到这两种情况
场景 1: 在某些模板中,脚本仅在放置在 顶部(即头部)时才有效。 但在元素底部时不起作用
<head>
<!--required scripts here e.g.-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js"></script>
</head>
<body>
<div class="content">
<!--elements that require scripts i.e. forms and button-->
</div>
<footer>
</footer>
</body>
场景 2:在某些模板中,脚本仅在放置在 底部(即页脚)时才有效。 但放在元素顶部时不起作用
<head>
</head>
<body>
<div class="content">
<!--elements that require scripts i.e. forms and button-->
</div>
<footer>
<!--required scripts here e.g.-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js"></script>
</footer>
</body>
我想了解这些场景背后的想法。是什么导致了这种行为?或者应该考虑什么?
【问题讨论】:
-
@8protons 我已经看到了参考资料,但我的问题不是要求放置脚本标签的最佳位置。我只是想了解为什么某些脚本不起作用
-
@8protons 这不是那个问题的真正副本,但那个链接是一个很好的阅读!感谢您的链接!
-
@OmariOmosa 我的误会;对不起!
标签: javascript jquery html