您的代码有一些问题:
- 您在select元素的ID上缺少打开的引号,因此:
<select name="dbType" id=dbType">
应该
<select name="dbType" id="dbType">
$('this')应该是$(this)
:不需要在括号内加上引号。要检索选项的值时,请使用.val()而不是.value()
当您初始化“选择”时,请在其前面加上一个var,除非您已在函数开始时完成它
尝试这个:
$('#dbType').on('change',function(){ if( $(this).val()==="other"){ $("#otherType").show() } else{ $("#otherType").hide() } });http://jsfiddle.net/ks6cv/
*与开关配合使用的 *UPDATE :
$('#dbType').on('change',function(){ var selection = $(this).val(); switch(selection){ case "other": $("#otherType").show() break; default: $("#otherType").hide() }});*带有jQuery和jQuery-UI链接的 *UPDATE :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script><script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>



