基于jquery实现二级联动效果
本文实例为大家分享了jquery实现二级联动的具体代码,供大家参考,具体内容如下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>二级联动</title> <script src="http://apps.bdimg.com/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $("#province").change(function(){ $("#province option").each(function(i,o){ if($(this).attr("selected")) { $(".city").hide(); $(".city").eq(i).show(); } }); }); $("#province").change(); }); </script> </head> <body> <select id="province"> <option>----请选择省份----</option> <option>北京</option> <option>上海</option> <option>江苏</option> </select> <select class="city"> <option>----请选择城市----</option> </select> <select class="city"> <option>东城</option> <option>西城</option> <option>崇文</option> <option>宣武</option> <option>朝阳</option> </select> <select class="city"> <option>黄浦</option> <option>卢湾</option> <option>徐汇</option> <option>长宁</option> <option>静安</option> </select> <select class="city"> <option>南京</option> <option>镇江</option> <option>苏州</option> <option>南通</option> <option>扬州</option> </select> </body> </html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17