<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" src="jquery-1.3.1.js" type="text/javascript">
$("#test").click(function(){alert("您点击了文字");});
</script>
</head>
<body>
<p id="test">你好</p>
</body>
</html>
我点你好俩字啥怎么啥反应都没有呢

解决方案 »

  1.   

    <script language="javascript" src="jquery-1.3.1.js" type="text/javascript">
    $("#test").click(function(){alert("您点击了文字");});
    </script>改成
    <script language="javascript" src="jquery-1.3.1.js" type="text/javascript"></script>
    <script language="javascript">
    $("#test").click(function(){alert("您点击了文字");});
    </script>不能既加载src又写代码
      

  2.   

    $(function() {
      $("#test").click(function(){alert("您点击了文字");});
    });
    要在dom加载完执行
      

  3.   

    <script language="javascript" src="jquery-1.3.1.js" type="text/javascript"/>
    <script type="text/javascript">
    $("#test").click(function(){alert("您点击了文字");});
    </script>
      

  4.   

    <script src="jquery-1.3.1.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#test").click(function(){alert("您点击了文字");});
    });
    </script>
      

  5.   

    改成了
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script src="jquery-1.3.1.js" type="text/javascript"></script>
    <script type="text/javascript">
    $("#test").click(function(){alert("您点击了文字");});
    </script>
    </head>
    <body>
    <p id="test">你好</p>
    </body>
    </html>
    还是不对呀
      

  6.   

    test还没加载呢,不会有click的
      

  7.   

    难道jQuery开头一定要写$(document).ready()吗?
      

  8.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script src="jquery-1.3.1.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function() {
      $("#test").click(function(){alert("您点击了文字");});
    });
    </script>
    </head>
    <body>
    <p id="test">你好</p>
    </body>
    </html>