小编use*_*266的帖子

想要根据下拉框选择显示/隐藏div

只有在下拉框中选择"业务使用"时,我才想让jQuery show div id ='business'.

这是我的代码:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$('#purpose').on('change', function() {
  if ( this.value == '1');
  {
    $("#business").show();
  }
  else
  {
    $("#business").hide();
  }
});
});
</script>
<body>
<select id='purpose'>
<option value="0">Personal use</option>
<option value="1">Business use</option>
<option value="2">Passing on to a client</option>
</select>
<div style='display:none;' id='business'>Business Name<br/>&nbsp;
<br/>&nbsp;
    <input type='text' class='text' name='business' value size='20' />
    <br/>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)

和JSFiddle:http://jsfiddle.net/2kGzZ/1/

html javascript jquery input

27
推荐指数
4
解决办法
14万
查看次数

标签 统计

html ×1

input ×1

javascript ×1

jquery ×1