This plugin allows to conditionally display elements based on an input element value. It has inline-options feature which allows to do this very easily, something similar to angular JS's ng-if
feature.
Please select a fruit - Hint: Banana has more options !
<select id="fruits"> <option value="apple">Apple</option> <option value="banana">Banana</option> <option value="mango">Mango</option> </select> <!-- Plugin options given inline --> <div class="banana-section" data-condr-input="#fruits" data-condr-value="banana" data-condr-action="simple?show:hide" data-condr-events="click"> Here are the Banana options .. </div> <script> $(document).ready(function(){ $( '.banana-section' ).conditioner(); }); </script>
Select any position of horizontal to get more options on it.
<select class="boxOrientation"> <option value="vl-left">Vertical - Left</option> <option value="vl-right">Vertical - Right</option> <option value="hl-top">Horizontal - Top</option> <option value="hl-bottom">Horizontal - Bottom</option> </select><br/> <!-- Here we are looking for a pattern "hl" in the input's value --> <div class="horizontalOptions" data-condr-value="hl" data-condr-input=".boxOrientation" data-condr-action="pattern?slideDown:fadeOut" data-condr-events="change"> Here are some options for horizontal box. </div> <script> $(document).ready(function(){ $( '.horizontalOptions' ).conditioner(); }); </script>
Input elements can also be selected in relative to the element which has to be hidden.
Type "hello" | |
Welcome ! | Here are some more options |
<table> <tr> <td>Type "hello"</td> <td><input type="text" /></td> </tr> <tr class="greetings" data-condr-value="hello" data-condr-input="(prev::)(find::input[type='text'])" data-condr-action="simple?show:hide" data-condr-events="keyup change"> <td>Welcome !</td> <td>Here are some more options</td> </tr> </table> <script> $(document).ready(function(){ $( '.greetings' ).conditioner(); }); </script>
Through external options multiple values can be checked.
<ul> <li><input type="text" class="step1" placeholder="type hey" /></li> <li><label><input type="radio" name="step2" value="disagree" /> I Disagree</label> <label><input type="radio" value="agree" name="step2" />I Agree</label> </li> <li><label><input type="checkbox" id="step3"/> I once again agree to the terms</label></li> </ul> <div class="multipleConditions">Ah ! Finally ... you can <button>Submit</button></div> <script> $('.multipleConditions').conditioner({ conditions: [ { input: '.step1', type: 'simple', value: 'hey' }, { input: '[name=step2]', type: 'simple', value: 'agree' }, { input: '#step3' }, ], events: 'click keyup', onTrue: function(){ $(this).fadeIn( 'slow' ); }, onFalse: function(){ $(this).slideUp( 'slow' ); } }); </script>