Saturday, 29 October 2016

jQuery - same function used by multiple IDs (multiple controls)

Watch this example on YouTube


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   
    <script  type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#Button1, #TextBox1 , #CheckBox1').click(function () {
                alert('control clicked');
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" class='rb' runat="server" Text="Button" />
        <asp:CheckBox ID="CheckBox1" class='rb' runat="server" />
        <asp:TextBox ID="TextBox1" class='rb' runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

No comments:

Post a Comment