2015-06-22 31 views
0

如何使用jQuery

<script> $(function() { 
 
      $("#tabs").tabs(); }); 
 
    </script>
<div id="tabs"> 
 
     <ul> 
 
      <li><a href="#tabs-1">tab1</a></li> 
 
      <li><a href="#tabs-2">tab2</a></li> 
 
      <li><a href="#tabs-3">tab3</a></li> 
 
     </ul> 
 
     
 
    <div id="tabs-1"> 
 
    </div> 
 
    <div id="tabs-2"> 
 
    </div> 
 
    <div id="tabs-3"> 
 
    </div> 
 

 
    </div>
<div id="tabs"> 
 
     <ul> 
 
      <li><a href="#tabs-1">Reg</a></li> 
 
      <li><a href="#tabs-2">Summery</a></li> 
 
      <li><a href="#tabs-3">Advanced Search</a></li> 
 
     </ul> 
 
     
 
<div id="tabs-1"> 
 
</div> 
 
<div id="tabs-2"> 
 
</div> 
 
<div id="tabs-3"> 
 
    <table style="width: 100%;"> 
 
          <tr> 
 
           <td> 
 
            Company: 
 
           </td> 
 
           <td> 
 
            <asp:DropDownList ID="ddlCompanies" runat="server" CssClass="dropdown" Width="250px"> 
 
            </asp:DropDownList> 
 
           </td> 
 
          </tr> 
 
          <tr> 
 
           <td> 
 
            &nbsp; 
 
           </td> 
 
           <td> 
 
            <asp:Button ID="btnSearchTotal" runat="server" OnClick="btnSearchTotal_Click" Text="Search" 
 
             Width="100px" CssClass="greenbutton" /> 
 
           </td> 
 
          </tr> 
 
          <tr> 
 
           <td> 
 
            &nbsp; 
 
           </td> 
 
           <td> 
 
            &nbsp; 
 
           </td> 
 
          </tr> 
 
          <tr> 
 
           <td colspan="2"> 
 
            <asp:GridView ID="gdvAuthorize" runat="server" AutoGenerateColumns="False" Width="777px" 
 
             OnRowCommand="gdvAuthorize_RowCommand" OnRowEditing="gdvAuthorize_RowEditing" 
 
             CssClass="mGrid"> 
 
             <Columns> 
 
              <asp:BoundField DataField="SlipYear" HeaderText="Slip Year" /> 
 
              <asp:BoundField DataField="SlipMonthName" HeaderText="Slip Month" /> 
 
              <asp:BoundField DataField="SlipCategoryName" HeaderText="Slip Category Name"></asp:BoundField> 
 
              <asp:BoundField DataField="TotalCount" HeaderText="Total Count" /> 
 
              <asp:ButtonField CommandName="SELECT" ImageUrl="~/images/icon_view.gif" ButtonType="Image"> 
 
               <ItemStyle Width="20px" /> 
 
              </asp:ButtonField> 
 
              <asp:TemplateField HeaderText="SlipMonthID" Visible="False"> 
 
               <ItemTemplate> 
 
                <asp:Label ID="SlipMonth" runat="server" Text='<%# Bind("SlipMonth") %>'></asp:Label> 
 
               </ItemTemplate> 
 
              </asp:TemplateField> 
 
             </Columns> 
 
            </asp:GridView> 
 
           </td> 
 
          </tr> 
 
         </table> 
 
        </p> 
 
       </div> 
 
       <div id="tabs-2"> 
 
        <p> 
 
         <table style="width: 100%;"> 
 
          <tr> 
 
           <td> 
 
            Company: 
 
            <td> 
 
             <asp:DropDownList ID="ddlCompany" runat="server" CssClass="dropdown" Width="250px"> 
 
             </asp:DropDownList> 
 
            </td> 
 
          </tr> 
 
          <tr> 
 
           <td> 
 
            Slip Category: 
 
            <td> 
 
             <asp:DropDownList ID="ddlSlipCategory" runat="server" CssClass="dropdown" Width="125px"> 
 
             </asp:DropDownList> 
 
             <asp:Label ID="lblError1" runat="server" ForeColor="Red" Text="Select Category"></asp:Label> 
 
            </td> 
 
          </tr> 
 
          <tr> 
 
           <td> 
 
            Slip Year: 
 
           </td> 
 
           <td> 
 
            <asp:DropDownList ID="ddlSlipYear" runat="server" CssClass="dropdown" Width="125px"> 
 
            </asp:DropDownList> 
 
            <asp:Label ID="lblError2" runat="server" ForeColor="Red" Text="Select Year"></asp:Label> 
 
           </td> 
 
          </tr> 
 
          <tr> 
 
           <td> 
 
            Slip Month: 
 
           </td> 
 
           <td> 
 
            <asp:DropDownList ID="ddlSlipMonth" runat="server" CssClass="dropdown" Width="125px"> 
 
            </asp:DropDownList> 
 
           </td> 
 
          </tr> 
 
          <tr> 
 
           <td> 
 
            &nbsp; 
 
           </td> 
 
           <td> 
 
            <asp:Button ID="Button2" runat="server" CssClass="greenbutton" OnClick="btnSearch_Click" 
 
             Text="Search" Width="100px" /> 
 
           </td> 
 
          </tr> 
 
         </table> 
 
        </p> 
 
       </div> 
 
</table> 
 

 
</div> 
 

 
</div>

這裏是我目前使用的標籤function.In TAB3內容我正在執行搜索功能和負載搜索數據的代碼重定向到一個特定的標籤一個數據網格view.But當沒有數據從搜索功能選項卡將自動重定向到標籤1,我如何留在tab3沒有重定向到標籤1?

+0

你能詳細說明一下使用一些代碼嗎? – Blip

+0

編輯你的問題,並在評論中添加代碼,這將是更有幫助的 – Blip

+0

你在哪裏代碼爲*當沒有數據從搜索功能選項卡將自動重定向到選項卡1 *? – Blip

回答

0

使用click方法。如果在選項卡3上沒有返回結果,請嘗試:

$('[href="#tabs-3"]').click(); 

無論結果如何,這將返回兩個選項卡3。

+0

它總是重定向到標籤3(像默認標籤)? – thilim9

+0

如果你把它放在 $(document).ready(function(){/ ** here ** /}); ,然後是的 – oMiKeY