例:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="js/jquery-2.0.0.js"></script>
        <script>
            var j = "";
            $(function(){
                j = 1;
                $("#btn").click(function(){ //函数在$(function(){})内
                    alert(j);
                });
            });
        </script>
    </head>
    <body>
        <input type="button" value="按钮" id="btn" />
    </body>
</html>

 

相关文章:

  • 2022-12-23
  • 2021-10-30
  • 2022-01-08
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-12-23
相关资源
相似解决方案