There is a working code in jQuery, which, I think, can be optimized due to the if and else . However, I could not do it, I hope for your help. Code example:
$(document).ready(function() { $("#female").click(function() { $("#showFemale").show(); $("#showMale").hide(); $("#who").hide(); }); }); $(document).ready(function() { $("#male").click(function() { $("#showMale").show(); $("#showFemale").hide(); $("#who").hide(); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="showFemale">showFemale</div> <div id="showMale">showMale</div> <div id="who">who</div> <button id="female" val="female">female</button> <button id="male" val="male">male</button>