Jquery .change()函数在localhost上不起作用

以下代码适用于jsfiddle但不适用于localhost,你能帮帮我吗?

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script>
        $('.puankontrol').change(function() {
          var x = $(this).val() * 1;   
          if((x < 1) ||  (x > 5))
          {
              $(this).val(3);
              alert("Please enter value between 1-5!");
          }
        });
    </script>
</head>
<body>

     <form>
      <input class="puankontrol" type="text" name="puan"/><BR>
      <input class="puankontrol" type="text" name="puan"/><BR>
      <input class="puankontrol" type="text" name="puan"/><BR>
    </form>
    <div id="other">
      Trigger the handler
    </div>

</body>
</html>

`

解决方法

尝试

$(document).ready(function(){
   //change function declaration.
});

也使用< script type =“text / javascript”>用于添加脚本标记.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...