如何告诉Bootstrap Carousel跳过元素或类? [英] How to tell Bootstrap Carousel to skip an element or class?

查看:115
本文介绍了如何告诉Bootstrap Carousel跳过元素或类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Bootstrap Carousel用于Tumblr,效果很好.但是,在主题自定义页面上,Tumblr在HTML的左,右和中心添加了JavaScript.这导致旋转木马断裂,因为下一个元素是意外的.

I'm using Bootstrap Carousel for Tumblr and it works great. However, on the theme customization page Tumblr adds JavaScript to the HTML left, right and center. That's causing the carousel to break, because the next element is unexpected.

要简单地将其放在代码中,它看起来像这样

To simply put it in code it looks like this

<div class="carousel-inner">
  <div class="active item"></div>
  <script class="custom-js-code">/* bunch of stuff go here */</script>
  <div class="item"></div>
  <script class="custom-js-code">/* bunch of stuff go here */</script>
  <div class="item"></div>
  <script class="custom-js-code">/* bunch of stuff go here */</script>
</div>

实时预览

删除JS是不可能的,因此我需要一种方法来告诉轮播使用<script>标记或custom-js-code类跳过这些元素.

Removing the JS is out of the question, so I need a way to tell the carousel to skip those elements using the <script> tag or the custom-js-code class.

有什么想法吗?

推荐答案

如果可能的话,升级到Bootstrap 3.2.0,因为该版本仅遍历类为.item的子级.

If possible upgrade to Bootstrap 3.2.0 as that version only iterates over children with class .item.

  • See http://codepen.io/ckuijjer/pen/RNaJbx for your code using Bootstrap 3.2.0
  • See https://github.com/twbs/bootstrap/blob/master/js/carousel.js for the carousel source code
  • See https://github.com/twbs/bootstrap/commit/4a2d337bf5f329eac1ca16208414ec1ebfe0546e for the changeset where this behavior changed

如果您无法升级到3.2.0版,也许看看是否有可能自己对源代码进行此更改.

If you can't move to version 3.2.0 perhaps see if it's possible to make this change to the source code yourself.

这篇关于如何告诉Bootstrap Carousel跳过元素或类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆