On Change The Select Value, Display Certain Div Content April 14, 2023 Post a Comment Here is the HTML code english french Solution 1: <select id="language"> <option value="en">english</option> <option value="fr">french</option> <option value="gr">german</option> </select> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <div> <div id="related_en_content"> english text </div> <div id="related_fr_content"> french text </div> <div id="related_gr_content"> german text </div> </div> <script> $("#language").on("change", function() { id = "related_" + $(this).val() + "_content"; $("#" + id).show().siblings().hide() }) </script> Copy Solution 2: $('[id^="related"]').not(':first').hide(); $("#language").on('change', function() { $("#related_"+this.value+"_content").show().siblings('[id^="related"]').hide(); }); Copy FIDDLE Solution 3: <select id="language" onchange:"javascript:handle_language(this)"> <option value="en">english</option> <option value="fr">french</option> <option value="gr">german</option> </select> <script> function handle_language(what){ document.getElementById('related_en_content').style.visibility='hidden'; document.getElementById('related_fr_content').style.visibility='hidden'; document.getElementById('related_gr_content').style.visibility='hidden'; if(what.value=="en"){ document.getElementById('related_en_content').style.visibility='visible'; } if(what.value=="fr"){ document.getElementById('related_fr_content').style.visibility='visible'; } if(what.value=="gr"){ document.getElementById('related_gr_content').style.visibility='visible'; } } </script> <div id="related_en_content"> english text </div> <div id="related_fr_content"> french text </div> <div id="related_gr_content"> german text </div> Copy Solution 4: $(document).ready(function(){ $("#language").change(function(e){ $('[id^="related"]') .not($('#related_'+$(this).val()+'_content')) .hide(); $('#related_'+$(this).val()+'_content').show() }); }); Copy Example. Share Post a Comment for "On Change The Select Value, Display Certain Div Content" Top Question Firefox, Chrome, Safari Have Grey Background For Mp4 Html5 Video Any video (that I can make) with a white background becomes… Red Border Still Appears On Inputs After Resetting An HTML 5 Form Firefox I have an HTML 5 form! Great, I'm excited! I decide to … Svg Animation And Firefox I'm struggle with SVG animation drawing, which is work … Form To Iframe Submission - How Do You Reset The Form After File Upload? I have a form that submits the results to an iframe. The su… How To Hide/show Tabs Using Jquery I have four tabs.On loading only the first tab is opened an… How To Save Html5 Geolocation Data To Python Django Admin? Is it possible to save the javascript html5 geolocation lat… How To Limit The Html Table Records In Each Page I am populating a table in my jsp which has more than 20 re… How To Display A Python String As Html In Jupyter Notebook In IPython notebook, I used to be able to display a python … How To Add Placeholder Field? I've been trying to add placeholder in input type='… Bounce Animation On A Scaled Object What is the best way to have an object scale and then perfo…