当我添加mobilejquery时,另一个库将停止工作


When I add mobile jquery another library stops its work.

当我添加js/jquery.mobile-14.5.min.js库时,上面所有的jquery都不工作,只有这个jquery.mabile-14.5.min.js jquery工作,导航停止了它的工作。那么,如何缩短这个jquery列表以正确的方式工作呢。

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js"  type="text/javascript"></script>
<script src="js/stickUp.min.js"  type="text/javascript"></script>
<script src="js/colorbox/jquery.colorbox-min.js"  type="text/javascript">   </script>
<!-- templatemo 395 urbanic -->
<script src="js/templatemo_script.js"  type="text/javascript"></script>    
<script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).ready(function () {
    $(".anchor_img").click(function (e) {
        //$('#overlay_form, #overlay-back').fadeIn(500);
        var targetPopup = $(this).attr('id');
        $("#hidden_id").attr('value',targetPopup);
           $.ajax({
            type: "POST",
            url: "popup.php?id="+targetPopup,
            dataType : 'json',
            data: $('#myform').serialize(), // serializes the form's elements.
           success: function(data)
           {
             //$(".overlay_form").fadeIn(1000);
             //$(".overlay_form").html(data);
             //$.each(data.employees, function(key, value){ 
                 //$(".overlay_form").load(data);
                 //$('.overlay_form').html(data);
                 //console.log(data);
                  $(".overlay_form").fadeIn();
                  $(".cover").fadeTo(500, 0.8);
                  $("#id>img").attr("src",data.fullpath);
                  $("#popup_img_id").attr("value",data.id);
                  console.log(data.fullpath);
                  //$("#cboxOverlay").show();
             //}); 
           }
       });
        e.preventDefault(); // avoid to execute the actual submit of the form.      
    });
    //close popup
    $(".close").click(function () {
        $(".overlay_form").fadeOut();
        $(".cover").fadeOut();
    });
        $('body').click(function(e) {
            if (!$(e.target).closest('.overlay_form').length){
                $(".overlay_form").fadeOut();
                $(".cover").fadeOut();
            }
        });
});

//maintain the popup at center of the page when browser resized
//$(window).bind('resize', positionPopup); 
</script> 
<script>
    $("#popup_submit").click(function (e) {
          var pname = $("#popup_user_name").attr('value');  
          var pmobile = $("#popup_user_mobile").attr('value');
          var pcomment = $("#popup_user_comment").attr('value');
          if(pname == "")
          {
            alert("Plz Enter Your Name");
            return false;
          }
          if(pmobile == "")
          {
            alert("Plz Enter Your Mobile");
            return false;
          }
          if(pcomment == "")
          {
            alert("Plz Enter Your Comment");
            return false;
          }
           $.ajax({
            type: "POST",
            url: "popup_msg.php",
            dataType : 'json',
            data: $('#myform_popup').serialize(), // serializes the form's elements.
           success: function(data)
           {
                alert("Message Sent !"); 
                $("#popup_user_name").val("");
                $("#popup_user_mobile").val("");
                $("#popup_user_comment").val("");
           }
       });
        e.preventDefault(); // avoid to execute the actual submit of the form.      
    });
</script>    
<script>
$("#popup_user_mobile").keypress(function (e) {
 //if the letter is not digit then display error and don't type anything
 if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
    //display error message
    $("#errmsg").html("Digits Only").show().fadeOut("slow");
        return false;
}
});
$("#user_mobile").keypress(function (e) {
 //if the letter is not digit then display error and don't type anything
 if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
    //display error message
    $("#contact_errmsg").html("Digits Only").show().fadeOut("slow");
        return false;
}
});
</script>

无法确定您可能遇到的所有冲突,但一个可能的问题是您将jQuery包含了两次。我建议重新设计您的脚本includes,这样您就只能一次引入jQuery。这可能可行,但这取决于您的脚本版本要求:

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js"  type="text/javascript"></script>
<script src="js/stickUp.min.js"  type="text/javascript"></script>
<script src="js/colorbox/jquery.colorbox-min.js"  type="text/javascript">   </script>
<!-- templatemo 395 urbanic -->
<script src="js/templatemo_script.js"  type="text/javascript"></script>    
<script src="js/jquery.mobile-1.4.5.min.js"></script>

我所做的唯一更改是删除了<script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>,它是在您包含jQuery-mobile之前插入的,因为您已经在第一行包含了jQuery。