- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
仅当单击按钮 #collapse_init
时,我才能根据 active
bool 变量将按钮上的文本更改为“全部显示”或“全部隐藏”
当我手动隐藏/折叠选项卡(一个接一个)时,按钮上的文本没有改变,我正在想办法解决这个问题。
** 目前笔无法正常工作 - 按钮无法正常工作(仅在“笔”中,在我的代码中它正在工作),它不会一次折叠/隐藏所有内容(也试图找出原因) .
var active = false;
$('#collapse_init').click(function () {
if (active) {
active = false;
$('.panel-collapse').collapse('hide');
$('.panel-title').attr('data-toggle', 'collapse');
$(this).text('Show all');
} else {
active = true;
$('.panel-collapse').collapse('show');
$('.panel-title').attr('data-toggle', '');
$(this).text('Hide all');
}
});
$('.accordion-toggle').click(function () {
var visible = $('.accordion-toggle:visible').length;
if(visible >0){
$('#collapse_init').text('Hide all');
}else{
$('#collapse_init').text('Show all');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<button id="collapse_init" class="btn btn-default ">Show all</button>
<hr>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
Collapsible Group Item #1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse ">
<div class="panel-body">
ONe Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
Collapsible Group Item #2
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse ">
<div class="panel-body">
Two Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
Collapsible Group Item #3
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse ">
<div class="panel-body">
Three Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
</div>
代码笔
最佳答案
添加此代码并尝试
$('.accordion-toggle').click(function () {
var visible = $('.accordion-toggle:visible').length;
if(visible >0){
$('#collapse_init').text('Hide all');
}else{
$('#collapse_init').text('Show all');
}
});
关于javascript - 折叠选项卡 "manually"不要更改启动按钮上的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44881530/
关闭。这个问题需要更多 focused .它目前不接受答案。 想要改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this q
我们如何手动启动滑动 Jquery 事件(例如用于点击事件的 $('div').click(); )? $('div').live('swipeleft'); 无法执行此操作。 最佳答案 根据您正在使
我想做一个std::function像可以处理存储多个重载的对象。 语法有点像这样:my_function . 或者,更明确地说: template struct type_list {}; temp
1. macvlan 简介 在 macvlan 出现之前,我们只能为一块以太网卡添加多个 ip 地址,却不能添加多个 mac 地址,因为 mac 地址正是通过其全球唯一性来标识一块以太网卡的,即便
我只想在 shell(或 perl)脚本中获取 MAN 页面的特定部分并打印它。 例如:仅 MAN 页面的 SYNOPSIS 部分 有没有标准的方法来做到这一点? 问候, 阿南丹 最佳答案 据我所知,
我正在使用以下代码为 Woocommerce 创建一个新的自定义订单状态。我遇到的问题是,在管理员中,状态显示为无样式。如何以类似于“处理”的方式设置自定义状态的样式? /* Adding a new
我希望在 MOSS 2007 中创建一个“在线手册”站点模板,以便创建多个站点,这些站点将保存有关一系列主题的静态信息。 我应该使用什么网站模板,我目前正在考虑发布网站,但 Wiki 可能有用? 我应
简单来说,我在客户的整个网站上使用外部 PHP 脚本来实现各种目的,例如获取搜索结果、更新内容等。 我将这些脚本保存在一个目录中: www.domain.com/scripts/scriptname0
在具有 Spring MVC 和 Spring Security 的 Web 应用程序中。 有没有办法手动设置 UserPrincipal? 我需要通过我的 web 应用程序的管理部分切换到另一个用户
我发现我可以使用migrations.RunSQL('some sql')为django项目中的postgres数据库设置列的默认值。 我目前正在通过添加列,makemigrations,然后删除列,
我的 web 应用程序(Spring3 + Hibernate3)始终使用使用 @Transactional 注释的服务类以及以下配置: 现在...我正在使用
我们是否可以手动登录用户并创建一个 TWTRSession 以便继续与 TwitterKit 一起使用?我已经尝试过: NSDictionary *twSessionInfo = [self.acco
我有这个功能: int cipher_file(char *file_path, uint8_t *key, int key_size){ FILE *file; size_t rea
仅当单击按钮 #collapse_init 时,我才能根据 active bool 变量将按钮上的文本更改为“全部显示”或“全部隐藏” 当我手动隐藏/折叠选项卡(一个接一个)时,按钮上的文本没有改变,
我正在尝试从 OpenCV 中重现 projectPoints() 方法的行为。 下面两张图中,红/绿/蓝轴是用OpenCV的方法得到的,而洋红/黄/青轴是用我自己的方法得到的: 图片1 图片2 用我
鉴于 LISP 显然可以用“LISP 微型手册”的“10 条规则”来表达 [1] [2] (这是真的吗?),是否有类似简洁的Scheme描述? 最佳答案 这里麦卡锡的“10 条规则”本质上是操作语义的
手动,我的意思是代码好像我需要迎合,就好像对象不是我期望的那样。 例如,我正在使用中继器。作为其中的一部分,我正在操纵 DataSource 属性。为此,我必须先检查以下内容: this.DataSo
这个问题在这里已经有了答案: Spring Data JPA Update @Query not updating? (5 个答案) 关闭 2 年前。 社区在 去年 审查了是否重新打开这个问题并将其
我真的是 Spring 的新手我正在使用 JSF+Hibernate+Spring 开发一个简单的 JEE 应用程序我在尝试更新 DAO 上的值时遇到了一些问题我确定问题与 Spring 配置 xml
我想对在Web应用程序中在服务器和客户端之间来回传输的数据进行加密。我会使用SSL,但是需要证书和专用IP地址。获得证书没有问题,但专用IP需要我升级到企业托管计划,该计划是在Web主机上每月支付20
我是一名优秀的程序员,十分优秀!