Skip to content

Instantly share code, notes, and snippets.

@koentjuh1
Created August 30, 2016 09:31
Show Gist options
  • Save koentjuh1/5912261c6e4b0d79d4e0ef4db9f968f8 to your computer and use it in GitHub Desktop.
Save koentjuh1/5912261c6e4b0d79d4e0ef4db9f968f8 to your computer and use it in GitHub Desktop.
Random addClass acitve
<div class="carousel-inner" role="listbox">
<div class="item" style="background-image: url(&quot;images/slider1.jpg&quot;);">
</div>
<div class="item" style="background-image: url(&quot;images/slider2.jpg&quot;);">
</div>
<div class="item" style="background-image: url(&quot;images/slider3.jpg&quot;);">
</div>
</div>
$('.item').eq(Math.floor((Math.random() * $('.item').length))).addClass("active");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment