javascript - Show/hide fields depending on select value parent/sub -


so, want show pvp/pk content based on server. not need script - have it. need how show fields. if custom selected, automatically shows custom - pvp field content, have option select pk field content. when no custom selected, automatically shows no custom - pvp field content, have option ot select pk field content. have simple show/hide fields content found (on here, think, when searching), don't know how add parent/sub (what need).

example of want:

example of want

current script: https://jsfiddle.net/aiphira/f9q0qjdr/

$(document).ready(function() {    $.viewmap = {      'view1' : $('#view1'),      'view2' : $('#view2')    };      $('#viewselector').change(function() {      // hide      $.each($.viewmap, function() { this.hide(); });      // show current      $.viewmap[$(this).val()].show();    }).change();  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <select id="viewselector">       <option value="view1">no custom</option>     <option value="view2">custom</option>  </select>    <div id="view1">  asd  </div>  <div id="view2">  qwe  </div>


Comments