Selectors
Use a select input to toggle show/hide on content areas.
Select inputs allow you to use a simple form control such as a dropdown input to conveniently hide and show
content in <divs>.
<div class="bootstrapr-selector">
<!-- The input selector -->
<form>
<select class="form-control input-lg" id="selector-1001001">
<option disabled="disabled" value="" selected="selected">
SELECT
</option>
<option value="#content-div-1">Show section 1</option>
<option value="#content-div-2">Show section 2</option>
<option value="#content-div-3">Show section 3</option>
<option value="#content-div-4">Show section 4</option>
</select>
</form>
<!-- The content divs -->
<div id="content-div-1" class="selector-content hidden">
<p>This is the content for section 1</p>
</div>
<div id="content-div-2" class="selector-content hidden">
<p>This is the content for section 2</p>
</div>
<div id="content-div-3" class="selector-content hidden">
<p>This is the content for section 3</p>
</div>
<div id="content-div-4" class="selector-content hidden">
<p>This is the content for section 4</p>
</div>
</div>
<!-- bootstrapr-div -->
Custom CSS
Custom CSS is recommended to add marging and padding to the .
Required JS
Custom jQuery is required to hide and show the divs. Make sure to place the function inside a
document.ready function.
$("#selector-1001001").on("change", function() {
$(".bootstrapr-selector div").addClass("hidden");
var showDiv = $("#selector-1001001").val();
$(showDiv).removeClass("hidden");
});
Notes
×
Keep Selector Sets Unique
While you may place multiple selector dropdowns on a page...
do not
simply cut and paste the same selector again and again. Make sure to generate each new selector anew,
ensuring the random number assigned to each one stays unique and does not conlflict with the other sets on
the page.