评论:省市三级联动  [查看原文]

 9745  113  2
当前第1页 / 共1页
    Ki no??0
    2020/6/16 11:02:51
    //给省添加改变事件           
    $(".prove").change(function() {
        var $index1 = $(this).find(":selected").index();
        window.$index1 = $index1; //清空城市列表以便再次添加             
        $(".city").empty();
        $(".county").empty();
        $("<option></option>").text("请选择城市").appendto(".county") citys[$index1].foreach(addcity);
        big[$index1][0].foreach(addcounty);
    })
    回复
    Ki no??0
    2020/6/16 11:01:43

    改进了一下,解决了选择省之后无法自动选到县的问题 

    <!doctype html>
    <html>
    
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>document</title>
    </head>
    <style>
        * {margin: 0;padding: 0;  }select {width: 150px;height: 30px;    }
    </style>
    
    <body> <select name=""></select> <select name=""></select> <select name="" value="122"></select> </body>
    
    </html>
    回复

讨论这个项目(2)回答他人问题或分享插件使用方法奖励jQ币

取消回复