jquery lib不包括在内


jquery lib is not including

我已经开发了我的插件,但我遇到了一些奇怪的问题。当我使用此代码包含Jquery-lib文件时

   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

它工作得很好,但当我将Jquery Lib包含在这段代码中时,它就不起的作用了

   <script src="<?php echo plugins_url(); ?> /kp_contactus/js/jquery.js"> </script>

路径是正确的,我已经检查过,本地Jquery lib版本是jQuery v1.10.2

我得到控制台错误是…

未捕获的类型错误:对象[object object]的属性"$"不是函数?page_id=19:108(匿名功能)

有人能告诉我它出了什么问题吗?

   $('#contact').validate({
        /* Making ajax request on successfull submition*/
       submitHandler : function (form){
           var name=$("#firstname").val();
           var email=$("#useremail").val();
           var contact=$("#mobile").val();
           var type=$("#type").val();
           var msg=$("#message").val();
           $("#send").attr("disabled",true).html("Sending");
           var data = { 'name': name, 'email' : email, 'contact' : contact, 'type' : type, 'msg' : msg };
           $.ajax({
               url : '<?php echo plugins_url();?>'+'/kp_contactus/kp_contact_config.php',
               type : 'POST',
               data : {contact:JSON.stringify(data)},
               success : function (msg)
               {
                  $("#info").fadeIn().html(msg).fadeOut(5000);
                  $("#send").attr("disabled",false).html("Send");
                  $("#contact").find("input").val("");
                  $("#contact").find("textarea").val("");
               }
           })
       },

在为WordPress编写jQuery代码时,我经常使用jQuery('#getId')而不是$('#getId'),它很有效,你试过吗?

这里有一篇有趣而简短的文章可以帮助解释它。

许多JavaScript库使用$作为函数或变量名,就像jQuery一样。在jQuery的情况下,$只是jQuery的一个别名,因此所有功能都可以在不使用$的情况下使用。有可能发生冲突,因此使用jQuery关键字而不是$

参考您的此评论"现在我收到此错误"Uncaught ReferenceError:JQuery未定义"这意味着找不到库对此进行双重检查。

正如Zaheer在http://中指出的那样(其他人指出的不一定需要)

有时不同的库在$上发生冲突。

<script src="other_lib.js"></script>
<script src="jquery.js"></script>
<script>
$.noConflict(); // releases $ from jQuery
jQuery( document ).ready(  // you must need to use jQuery here
 function( $ ) { // you passed $ as a parameter for jQuery
   // Use jQuery code with $ keyword
    $( "div a" ).show();
 });
// Use other library with $ keyword
$("content").style.display = "none";
</script>