1、按钮组效果如图:
HTML代码:
<div class="row "> <div class="form-group col-sm-7"> <div class="btn-group"> <asp:HiddenField ID="hidden_btnActive" runat="server" /> <asp:Button ID="Button1" runat="server" Text="当天" OnClick="CurrentDay_Click" CssClass="btn btn-default" OnClientClick ="GetDayWeekMonthAll(this)"/> <asp:HiddenField ID="Hidden_CurrentDayDate" runat="server" /> <asp:Button ID="Button2" runat="server" Text=" 周 " OnClick="CurrentWeek_Click" CssClass="btn btn-default " OnClientClick="GetDayWeekMonthAll(this)" /> <asp:HiddenField ID="Hidden_CurrentWeekDate" runat="server" /> <asp:Button ID="Button3" runat="server" Text=" 月 " OnClick="CurrentMonth_Click" CssClass="btn btn-default " OnClientClick="GetDayWeekMonthAll(this)"/> <asp:HiddenField ID="Hidden_CurrentMonthDate" runat="server" /> <asp:Button ID="Button4" runat="server" Text="全部" OnClick="CurrentALL_Click" CssClass="btn btn-default " OnClientClick="GetDayWeekMonthAll(this)" /> </div> </div> </div>
JS代码:
//点击 当天、周、月、全部 function GetDayWeekMonthAll(obj) { $('#<span style="font-family: Arial, Helvetica, sans-serif;">hidden_btnActive</span>').val($(obj).attr('id'));//记录点击的ID }
【Bootstrap3.0建站笔记四】按钮组,连接在一起使用
时间: 2024-10-24 12:01:44