Toggle Content Visibility With Checkbox/Radio/Select Elements - jQuery CiaoyuToggle

Toggle Content Visibility With Checkbox/Radio/Select Elements - jQuery CiaoyuToggle

CiaoyuToggle is a small jQuery content toggle plugin used for conditionally showing & hiding elements based on the value(s) of a checkbox, radio button, and/or select option.

1. Include the minified version of the jQuery CiaoyuToggle plugin after jQuery library.

<script src="" 
<script src="js/ciaoyuToggle.js"></script>

2. Hide the element you wan to toggle the visibility.

[data-ciaoyu-toggle] {
  display: none;

3. Specify the target toggle element in the data-ciaoyu-toggle and data-ciaoyu-val attributes: .

<input class="ciaoyu-toggle" type="checkbox" id="toggle-1">
<input class="ciaoyu-toggle" type="radio" id="toggle-2">
<select class="ciaoyu-toggle" id="toggle-3">
  <option value="1">1</option>
<div data-ciaoyu-toggle="toggle-1">
<div data-ciaoyu-toggle="toggle-2">
<div data-ciaoyu-toggle="toggle-3" data-ciaoyu-val="1">

4. The plugin also allows you to toggle multiple elements:

<div data-ciaoyu-toggle="toggle-1,toggle-2">...</div>
<div data-ciaoyu-toggle="toggle-3" data-ciaoyu-val="1,2,3">...</div>

5. Combine the checkbox and select element.

<div data-ciaoyu-toggle="toggle-1,toggle-2">
<div data-ciaoyu-toggle="toggle-3" data-ciaoyu-val="1,2,3">

This awesome jQuery plugin is developed by Canboo. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 18.01.2019
  • Source