Randomize
Randomly picks one of the child elements.
Configuration
selector
(jQuery selector)- Default undefined. When undefined it selects all the children. This attribute specifies the child elements to be displayed.
shuffle
(boolean)- If true, it will shuffle the order of child components.
toggle
(CSS class)- Class name that will be toggled in child components and it will toggle the specified class of child components to reveal.
number
(number)- Optional and use with toggle. Number of child components to be displayed when toggled. Default is set to
1
.
Show one random image
Below example shows one image out of three images randomly. Probability of 33% that a different image will be display on the next page refresh. The name of class that will be toggled is 'hide' in the following three img
s.
Source code
<div class="mrgn-bttm-md"" data-wb-randomize='{ "shuffle": true, "selector": "img", "toggle": "hide" }'>
<img class="full-width hide"
src="../../demos/tabs/img/investinourfuture.jpg" alt="Invest in our Future" />
<img class="full-width hide"
src="../../demos/tabs/img/flytheskies.jpg" alt="Fly the Skies" />
<img class="full-width hide"
src="../../demos/tabs/img/protect-environment.jpg" alt="Protect Environment" />
</div>
Randomize tables rows
All five (5) table rows get shuffled on page load.
Column A | Column B |
---|---|
Row 1, column A | Row 1, column B |
Row 2, column A | Row 2, column B |
Row 3, column A | Row 3, column B |
Row 4, column A | Row 4, column B |
Row 5, column A | Row 5, column B |
Source code
<table class="table table-bordered">
<caption>Data sample</caption>
<thead>
<tr>
<th>Column A</th>
<th>Column B</th>
</tr>
</thead>
<tbody data-wb-randomize='{ "shuffle": true }'>
<tr>
<td>Row 1, column A</td>
<td>Row 1, column B</td>
</tr>
<tr>
<td>Row 2, column A</td>
<td>Row 2, column B</td>
</tr>
<tr>
<td>Row 3, column A</td>
<td>Row 3, column B</td>
</tr>
<tr>
<td>Row 4, column A</td>
<td>Row 4, column B</td>
</tr>
<tr>
<td>Row 5, column A</td>
<td>Row 5, column B</td>
</tr>
</tbody>
</table>
Randomize tables rows and toggle 2 rows
All five (5) table rows get shuffled on page load and 2 of them get the CSS class warning
.
Column A | Column B |
---|---|
Row 1, column A | Row 1, column B |
Row 2, column A | Row 2, column B |
Row 3, column A | Row 3, column B |
Row 4, column A | Row 4, column B |
Row 5, column A | Row 5, column B |
Source code
<table class="table table-bordered">
<caption>Data sample</caption>
<thead>
<tr>
<th>Column A</th>
<th>Column B</th>
</tr>
</thead>
<tbody data-wb-randomize='{ "shuffle": true, "toggle": "warning", "number": 2 }'>
<tr>
<td>Row 1, column A</td>
<td>Row 1, column B</td>
</tr>
<tr>
<td>Row 2, column A</td>
<td>Row 2, column B</td>
</tr>
<tr>
<td>Row 3, column A</td>
<td>Row 3, column B</td>
</tr>
<tr>
<td>Row 4, column A</td>
<td>Row 4, column B</td>
</tr>
<tr>
<td>Row 5, column A</td>
<td>Row 5, column B</td>
</tr>
</tbody>
</table>
Report a problem on this page
- Date modified: