问题
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>
Live preview
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.
Any ideas?
回答1:
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
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.
来源:https://stackoverflow.com/questions/27468089/how-to-tell-bootstrap-carousel-to-skip-an-element-or-class