手风琴的显示/隐藏按钮(文本)

发布于 2024-09-04 21:50:06 字数 2062 浏览 7 评论 0原文

有一个带有“视图”按钮的手风琴,可以打开关闭手风琴面板(使用 jQuery 工具),但我想要根据状态显示“显示/隐藏”的动态文本...

这是手风琴的代码在 asp.NET 中

<div id="accordion">
  <% foreach (var eventModel in ViewModel)
     { %>

     <% var isNewMonth = eventModel.Date.Month != previousMonth; %>

     <% if (isNewMonth && previousMonth > 0)
        { %></table></div><% } %>

     <% previousMonth = eventModel.Date.Month; %>

     <% if (isNewMonth)
        { %>
        <h2><%= string.Concat(eventModel.Date.ToString("MMMM"), " ", eventModel.Date.Year) %> <span style="float:right;"><a href="#" class="button blue small">View</a></span></h2>
        <div class="pane" style="display:block">
            <table id="listTable" width="100%" cellpadding="3" cellspacing="0" border="0"> 
            <tr align="left" valign="top"><th align="left" valign="top">Date</th><th align="left" valign="top">Event</th><th align="left" valign="top">Event Type</th></tr>
     <% } %>

            <tr align="left" valign="top"><td align="left" valign="top"><b><span id="date" style="float:left;"> <%= string.Concat(eventModel.Date.ToString("MMMM"), " ", eventModel.Date.Day, " </span><span id='day' style='float:left'>" + eventModel.Date.DayOfWeek + "</span> ")%></b></td><td align="left" valign="top" ><%= Html.ActionLink(eventModel.Name.Truncate(40), "event", "register", new { id = eventModel.Id }, null)%></td><td align="left" valign="top"><%= string.Concat(" ", eventModel.Sport)%></td></tr>

  <% } %>

  <% if (ViewModel.Count > 0)
     { %></table></div><% } %>
</div>

,这是使用 jQuery 的初始化脚本:

 
$(function() { 
$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: 0});
$(".small").click(function() { moveToTop(); });

});

 

Have an accordion with a "view" button to open close the accordion panel (using jQuery Tools), but I would like to have dynamic text that says "show/hide" depending on the state...

Here is the code for the accordion in asp.NET

<div id="accordion">
  <% foreach (var eventModel in ViewModel)
     { %>

     <% var isNewMonth = eventModel.Date.Month != previousMonth; %>

     <% if (isNewMonth && previousMonth > 0)
        { %></table></div><% } %>

     <% previousMonth = eventModel.Date.Month; %>

     <% if (isNewMonth)
        { %>
        <h2><%= string.Concat(eventModel.Date.ToString("MMMM"), " ", eventModel.Date.Year) %> <span style="float:right;"><a href="#" class="button blue small">View</a></span></h2>
        <div class="pane" style="display:block">
            <table id="listTable" width="100%" cellpadding="3" cellspacing="0" border="0"> 
            <tr align="left" valign="top"><th align="left" valign="top">Date</th><th align="left" valign="top">Event</th><th align="left" valign="top">Event Type</th></tr>
     <% } %>

            <tr align="left" valign="top"><td align="left" valign="top"><b><span id="date" style="float:left;"> <%= string.Concat(eventModel.Date.ToString("MMMM"), " ", eventModel.Date.Day, " </span><span id='day' style='float:left'>" + eventModel.Date.DayOfWeek + "</span> ")%></b></td><td align="left" valign="top" ><%= Html.ActionLink(eventModel.Name.Truncate(40), "event", "register", new { id = eventModel.Id }, null)%></td><td align="left" valign="top"><%= string.Concat(" ", eventModel.Sport)%></td></tr>

  <% } %>

  <% if (ViewModel.Count > 0)
     { %></table></div><% } %>
</div>

Here is the initialization script using jQuery:

 
$(function() { 
$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: 0});
$(".small").click(function() { moveToTop(); });

});

 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烙印 2024-09-11 21:50:06

您可以使用切换方法: http://api.jquery.com/toggle/

You can use the toggle-Method: http://api.jquery.com/toggle/

久夏青 2024-09-11 21:50:06

请注意,如果您不想处理大量脚本,您可以使用手风琴中的图标选项并显示显示/隐藏的图像。

看这里

http://jqueryui.com/demos/accordion/#option-icons


编辑

用于选择时选项卡上的显示/隐藏标签

$( "#accordian" ).tabs("#accordion div.pane", 
  {tabs: 'h2', 
  effect: 'slide', 
  initialIndex: 0
  select: function(event, ui) {
     //ui.panel is the current tab I think
     //you should be able to toggle a show/hide on each tab from here
  }
}
);

Note if you didnt want to deal with alot of script you could use the icon option in the accordian and display an image that says show/hide.

look here

http://jqueryui.com/demos/accordion/#option-icons


Edited

For a show/Hide label on the tab when selected

$( "#accordian" ).tabs("#accordion div.pane", 
  {tabs: 'h2', 
  effect: 'slide', 
  initialIndex: 0
  select: function(event, ui) {
     //ui.panel is the current tab I think
     //you should be able to toggle a show/hide on each tab from here
  }
}
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文