Jqery:bind ,unbind

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
      

        function test() {

            alert("事件被执行!");
        }
        $(document).ready(
          function(){
          $("#a1").bind("click",test);
          }
         
        );

        $("#a1").bind("click", function () {

            alert("事件被执行");
        });
        function test1() {

         
            $("#a1").unbind("click");
        }

     
      
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="#" id="a1"   >点击</a>
    <input type="button"  value="取消"  onclick="test1()"/>
    </div>
    </form>
</body>
</html>

你可能感兴趣的:(bind)