bootstrap collapse 控件学习

文章参考 

http://v3.bootcss.com/javascript/#collapse-example-accordion

 

隐藏样式: .collapse hides content

效果样式: .collapsing is applied during transitions

关闭样式: .collapse.in shows content

 

测试代码:

dsafdsafdsafdsafdsaf

 

备注:

1、如果class="collapse in"则是展开内容

2、内容的样式 class="well"

 

链接  触发 

 

 

备注:重点是href="#collapseExample"属性

 

按钮 触发

 

 备注:重点是aria-controls="collapseExample"属性

 

 

例子: 


  • Bootply
  • One itmus ac facilin
  • Second eros
Anim pariatur cliche reprehenderi
Anim pariatur cliche r
Anim pariatur cliche r

 备注:.panel-body 和 .list-group  可以相互替换

 

  

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as indata-parent="".

Nametypedefaultdescription
parent selector false If a selector is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the panel class)
toggle boolean true Toggles the collapsible element on invocation

Methods

.collapse(options)

Activates your content as a collapsible element. Accepts an optional options object.

复制
$('#myCollapsible').collapse({
  toggle: false
})

.collapse('toggle')

Toggles a collapsible element to shown or hidden.

.collapse('show')

Shows a collapsible element.

.collapse('hide')

Hides a collapsible element.

Events

Bootstrap's collapse class exposes a few events for hooking into collapse functionality.

Event TypeDescription
show.bs.collapse This event fires immediately when the show instance method is called.
shown.bs.collapse This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
hide.bs.collapse This event is fired immediately when the hide method has been called.
hidden.bs.collapse This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
复制
$('#myCollapsible').on('hidden.bs.collapse', function () {
  // do something…
})

 

你可能感兴趣的:(bootstrap collapse 控件学习)