我正在使用XSLT作为我的视图层,我想在我的页面中包含Jquery,所以我做了以下但是并不意味着该库仍然无效:
<script src="jquery-1.4.2.min.js" type="text/javascript"> </script>
<script type="text/javascript">
alert("_______");
$(document).ready() {
alert("Jquery is working");
});
</script>
注意:jquery-1.4.2.min.js
文件位于我的XSL文件所在的文件夹中,
我注意到的奇怪的是脚本中第一行的alert
不起作用,这意味着javascript根本就不起作用!!我在chrome,firefox和IE上尝试过相同的结果。
答案 0 :(得分:5)
尝试这样
$(document).ready(function(){
alert("Jquery is working");
});
答案 1 :(得分:1)
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
alert("_______");
$(document).ready(function () {
alert("Jquery is working");
});
</script>
答案 2 :(得分:0)
试试这个:
<script src="jquery-1.4.2.min.js" type="text/javascript"></script> //  remove this content
<script type="text/javascript">
alert("_______");
$(document).ready(function() {
alert("Jquery is working");
});
</script>
答案 3 :(得分:0)
我在这里找到了一个解决方案:https://raygun.com/blog/jquery-is-undefined/。我在下面的<script>window.jQuery || document.write('<script src="path/to/your/jquery_file.js"><\/script>')</script>
标记之前添加了这段代码</body>
,并成功删除了“未加载/找到jQuery”警告