【问题标题】:naming an ajax tab命名一个ajax选项卡
【发布时间】:2013-02-11 09:07:25
【问题描述】:

简单的问题(我希望)我有一系列 jQuery 选项卡,其中一些是 ajax 调用:

<ul>
        <li><a href="#item">Item</a></li>
        <li runat="server" id="specLi"><a href="#spec">Spec</a></li>
        <li runat="server" id="productionLi"><a href="ajaxProduction.aspx?itemId=<%=itemId %>"><span>Production</span></a></li>
        <li runat="server" id="qualLi"><a href="ajaxQuality.aspx?itemId=<%=itemId %>"><span>Quality</span></a></li>
        <li runat="server" id="customersLi"><a href="#customers"><span>Customers</span></a></li>
        <li runat="server" id="salesLi"><a href="ajaxSales.aspx?itemId=<%=itemId %>"><span>Sales</span></a></li>
        <li runat="server" id="suppliersLi"><a href="#suppliers"><span>Suppliers</span></a></li>
        <li runat="server" id="purchasesLi"><a href="ajaxPurchases.aspx?itemId=<%=itemId %>"><span>Purchases</span></a></li>
        <li runat="server" id="stockLi"><a href="ajaxStockMovement.aspx?itemId=<%=itemId %>"><span>Stk Movt</span></a></li>
        <li runat="server" id="NotesLi"><a href="#notes"><span>Notes</span></a></li>
    </ul>

我想使用 #anchor 链接到特定选项卡 - 这很好用。但是对于 Ajax 选项卡,我无法指定 #anchor 名称。在呈现的 html 中,我得到 ui-tabs-1 ui-tabs-2 等

有没有办法在#之后指定锚文本?

提前致谢

戈登

[更新] 明白了,只需要在a标签上加一个name="linkname"

【问题讨论】:

  • 您想将#name 添加到每个没有该功能的a 中吗?
  • 我可以链接到指定的锚点,即 page.html#spec 但对于 ajax 页面我不知道#name 是什么
  • 知道了,只需要在a标签上加一个name="linkname"
  • 我也想自定义命名我的 ajax 选项卡,因为我使用它来使它们成为书签: beforeActivate: function (event, ui) { location.hash = ui.newPanel.selector; },你知道自定义命名 ajax 选项卡的方法吗?
  • 找出方法。我只是使用 li 元素上的 aria-controls 属性来自定义命名通过 ajax 加载的选项卡

标签: jquery asp.net html


【解决方案1】:

如果你想将name 添加到a 标签,你可以有这样的东西。

文档:$.attr()

$(function(){

   $("ul li a").each(function(){  //just limiting to all anchors inside the list

         $(this).attr("name","add some name to it");

   });

});

【讨论】:

    【解决方案2】:

    试试这个:

    $(function(){    
       $("ul li a").each(function(){
             name=$(this).attr("href");
             $(this).attr("name",name);//this will set the href attribute of element to name attribute    
       });    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-27
      • 2018-09-27
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      相关资源
      最近更新 更多