Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery在Velocity 1.5中不工作_Jquery_Velocity - Fatal编程技术网

jQuery在Velocity 1.5中不工作

jQuery在Velocity 1.5中不工作,jquery,velocity,Jquery,Velocity,我试图在velocity模板中使用jquery实现以下代码,但jquery根本没有响应。我使用的是速度1.5 请提供解决方案 <script src="/CostTrackerReporting/WebContent/js/jquery-3.2.1.min.js"> </script> <script> $.noConflict(); $(document).ready(function(){ $("div.test").replaceWith("&

我试图在velocity模板中使用jquery实现以下代码,但jquery根本没有响应。我使用的是速度1.5

请提供解决方案

<script src="/CostTrackerReporting/WebContent/js/jquery-3.2.1.min.js"> </script>
<script>
$.noConflict();

$(document).ready(function(){
    $("div.test").replaceWith("<h1>TEST</h1>");
});
 </script>  



<div id="test">
    <p>TETSIGN</p>
</div>

$.noConflict();
$(文档).ready(函数(){
$(“div.test”)。替换为(“test”);
});
四联征


这是因为您在无冲突模式下使用jquery。这意味着您不能再使用$,而必须使用:

jQuery(document).ready(function(){
    jQuery("div.test").replaceWith("<h1>TEST</h1>");
});
jQuery(文档).ready(函数(){
jQuery(“div.test”)。替换为(“test”);
});

为什么呢?因为jQuery不会在任何其他库使用美元符号的情况下使用它。

“不工作”不是很有用。发生了什么?@Shubhra你能看一下控制台(例如通过右键单击->检查->控制台)并判断是否有错误消息吗?当我检查控制台时,我得到以下信息。。。。“网络错误:找不到404-”jquery-…min.js ReferenceError:$不是defined@Shubhra:引用JS文件时出现404错误,这意味着脚本标记中指向文件的链接不正确。这可能是文件名错误或本地主机出现问题。为了确保这是问题所在,请尝试用以下内容替换您的脚本标记:code.jquery.com/jquery-3.2.1.slim.min.js“>现在您正在从web获取jquery。如果它现在工作,您需要修复指向.js文件的链接。@user2672106:using,它正在工作……可能是我丢失了一些路径。谢谢