0

嗨,我使用了这个引导折叠代码,我希望用户在面板外点击后关闭这个折叠。我尝试使用这个脚本,但它仍然没有帮助我达到我的预期。有人可以帮忙吗。 编码

<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#viewmore" aria-expanded="false" aria-controls="collapseExample">
    Open this 
  </button>
</p>
<div class="collapse" id="viewmore">
  <div class="card card-body">
 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
</div>

剧本

$(document).click(function(e) {
    if (!$(e.target).is('.panel-body')) {
        $('.collapse').collapse('hide');        
    }
});
4

0 回答 0