<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'firstJquery.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="../js/jquery-2.0.3.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){debugger;
   jQuery("p").click(function(){
   jQuery(this).hide();
  });
});
</script>  </head>
  
  <body>
    <p>if you click me,i will disappear</p>
  </body>
</html>

解决方案 »

  1.   

    什么问题?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'firstJquery.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(document).ready(function(){
       jQuery("p").click(function(){
       jQuery(this).hide();
      });
    });
    </script>  </head>
      
      <body>
        <p>if you click me,i will disappear</p>
      </body>
    </html>
    去掉debugger
      

  2.   

    你好歹描述一下需求啊
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
     jQuery(document).ready(function(){//debugger;
        jQuery("p").click(function(){
        jQuery(this).hide();
       });
     });
     </script>
      

  3.   

    我下了一个jquery-2.0.3.js,放在webroot下的js文件中,我直接引用这个src="../js/jquery-2.0.3.js",用你上面src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"这个就没有问题。src="../js/jquery-2.0.3.js"这个路径也没有问题,但是jQuery就说我没有定义。请解释
      

  4.   

    debugger;这个好像是 ..net 里可以的。 
      

  5.   


    你这种我试了是可以的,我现在自己下载到本地的jquery类库,我这样引入就不行<script type="text/javascript" src="../js/jquery-2.0.3.js"></script>,路径没有任何问题。
      

  6.   


    你这种我试了是可以的,我现在自己下载到本地的jquery类库,我这样引入就不行<script type="text/javascript" src="../js/jquery-2.0.3.js"></script>,路径没有任何问题。
    说你没有定义的原因就是你的库没引入,所以你的相对路径或者JQ库的文件名肯定是由问题的。
    不要说肯定没问题,请仔细检查
      

  7.   


    你这种我试了是可以的,我现在自己下载到本地的jquery类库,我这样引入就不行<script type="text/javascript" src="../js/jquery-2.0.3.js"></script>,路径没有任何问题。
    说你没有定义的原因就是你的库没引入,所以你的相对路径或者JQ库的文件名肯定是由问题的。
    不要说肯定没问题,请仔细检查找到问题了,是这个<base href="<%=basePath%>">问题导致引用出问题了