利用jQuery联动菜单制作大屏查看

发布于:2015年12月31日 已被阅读

<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script>
(
function($){
$.fn.selInit 
= function(){return $(this).html("<option>请选择</option>");};
$.area 
= function(){
        $(
"#province").selInit();
        $(
"#city").selInit();
        $(
"#county").selInit();
        
var area = {
                北京:{北京:
"东城,西城,海淀,宣武,丰台"},
                江苏:{南京:
"江宁,六合,下关,浦口",无锡:"北塘,滨湖,江阴,宜兴"}
                
//
        };
        $.each(area,
function(p){$("#province").append("<option>"+p+"</option>");});
        $(
"#province").change(function(){
                $(
"#city").selInit();
                $(
"#county").selInit();
                $.each(area,
function(p,x){
                        
if($("#province option:selected").text() == p)
                        {
                                $.each(x,
function(c,cx){
                                        $(
"#city").append("<option>"+c+"</option>");
                                });
                                
                                $(
"#city").bind("change",function(){
                                        $(
"#county").selInit();
                                        $.each(x,
function(c,cx){
                                                
if($("#city option:selected").text() == c)
                                                        {
                                                                $.each(cx.split(
","),function(){
                                                                        $(
"#county").append("<option>"+this+"</option>");
                                                                });
                                                        }
                                        });
                                });
                        }
                });
        });
};
})(jQuery);
$(
function(){
        $(
"select").css("width","100px");
        $.area();
        });
</script>
</head>
<body>
    
<select id="province"><option>请选择</option></select>
       
<select id="city"><option>请选择</option></select>
       
<select id="county"><option>请选择</option></select>
</body>
</html>

最新发布
linux下svn提交忽略某些文件... (119)
使用批处理来批量更新、提交SVN... (116)
linux查看目录文件大小命令 (117)
linux tar打包压缩排除某个... (114)
Linux tar压缩和解压 (116)
SVN子命令add用法浅析 (111)
热门博文
网友FBI探案:马蓉iPad惊人发现... (43320)
优衣库这个广告拍的很真实,反应人性,... (10110)
霍金携手俄罗斯富豪耗资1亿美元寻找外... (4734)
如何才能查看PHP内置函数源代码... (1196)
微信支付开发当前URL未注册的解决方... (514)
《谁为爱情买单》中的经典面试 ... (414)
精华博文
[推荐]Centos7 安装配置 SVN (117)
easyswoole框架安装 (115)
php开启pecl的支持(推荐) (116)
1-10个恋爱表现:男朋友爱你程度到... (119)
女生喜欢你的10个程度,到第六个就可... (121)
Eclipse 没有Server选项... (153)
友情链接
我来忙 (110)