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>
本文展示了一个使用jQuery 1.2.6版本实现的选择器变化效果示例。当用户在第一个下拉列表中选择不同的选项时,会显示相应的第二个下拉列表,同时隐藏其他不相关的下拉列表。该示例通过简单的HTML结构和jQuery代码实现了动态更新子选择器的可见性。
3982

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



