<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
</head>
<body>
<select id="name1">
<option>请选择</option>
<option>北京</option>
<option>杭州</option>
<option>上海</option>
</select>
<select id="name2">
<option>请选择</option>
<option>北京1</option>
<option>北京2</option>
<option>北京3</option>
</select>
<select id="name3">
<option>请选择</option>
<option>杭州1</option>
<option>杭州2</option>
<option>杭州3</option>
</select>
<select id="name4">
<option>请选择</option>
<option>上海1</option>
<option>上海2</option>
<option>上海3</option>
</select>
<script>
$('#name1').change(function(){
var a=parseInt($(this).find('option:selected').index())+1;
var namenum="#name"+a;
alert(namenum);
$('#name4,#name3,#name2').css('display','none');
$(namenum).css('display','block');
$(namenum).attr('name','name');
})
</script>
</body>
</html>
网友评论