如何通过select显示/隐藏div.(jquery)

vee*_*vee 5 html jquery select show hide

我的代码:

<select id="select">
<option id="1" value="thai language">option one</option>
<option id="2" value="eng language">option two</option>
<option id="3" value="other language">option three</option>
</select>

<div id="form1">content here</div>
<div id="form2">content here</div>
<div id="form3">content here</div>
Run Code Online (Sandbox Code Playgroud)

我想要的是在选择选项1时显示div#form1并隐藏form2 + form3,或者选择选项2显示div#form2并隐藏form1 + form2

Pao*_*ino 15

$('#select').change(function() {
   $('#form1, #form2, #form3').hide();
   $('#form' + $(this).find('option:selected').attr('id')).show();
});
Run Code Online (Sandbox Code Playgroud)

请注意,ID不应以数字开头,但上面应该这样做.