日期:2014-05-16  浏览次数:20307 次

为什么点击没反应?

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>Demo</title>
<script type="text/javascript" src="../jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$("#button").click(function() { 
     alert("I'm Test Button"); 
 }); 
</script>
</head>

<body>
<input type="button" value="测试" id="button" name="button">
</body>
</html>


------解决方案--------------------
<html>
    <head>
        <title>Demo</title>
        <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
        <script type="text/javascript">
            $(function(){//jquery开始 必不可少
                $("#button").click(function() { 
                     alert("I'm Test Button"); 
                 }); 
            })
            
        </script>
    </head>
 
    <body>
            <input type="button" value="测试" id="button" name="button">
    </body>
</html>