Here is the HTML code
<select id="language">
<option value="en">english</option>
<option value="fr">french</option>
<option value="gr">german</option>
</select>
<div id="related_en_content">
english text
</div>
<div id="related_fr_content">
french text
</div>
<div id="related_gr_content">
german text
</div>
Every div related to one of the options in the select, I want replace div when changing the select option.
Here’s what I’ve tried:
$(document).ready(
function() {
$("#language").change(
function() {
$("#" + this.value).show().siblings().hide();
});
$("#language").change();
}
1 Answer