jQuery版本:1.2.6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
.sub{display:none;}
</style>
</head>
<body>
<select id="sel1">
<option>北京</option>
<option>安徽省</option>
</select>
<select class="sub">
<option>中关村</option>
<option>朝阳区</option>
</select>
<select class="sub">
<option>合肥</option>
<option>安庆</option>
</select>
<script type="text/javascript">
$(document).ready(function(){
$("#sel1").change(function(){
$("#sel1 option").each(function(i,o){
if($(this).attr("selected"))
{
$(".sub").hide();
$(".sub").eq(i).show();
}
});
});
$("#sel1").change();
});
</script>
</body>
</html>
以上内容来自AJAX实例站:
http://www.ajaxsamples.cn/html/1040.html
jQuery下拉联动示例
本文展示了一个使用jQuery实现的下拉菜单联动效果示例。当用户选择不同的省份选项时,相应的子区域会动态显示。此示例适用于网页中需要根据不同选项加载不同内容的场景。
3194

被折叠的 条评论
为什么被折叠?



