三级联动

栏目: jQuery · 发布时间: 7年前

内容简介:安卓若有需要还要再过一下....原生的安卓...貌似现在发展到flutter 安卓的发展越来偏向于写配置文件,,,这是趋势,,,所有的页面展示都趋向于写配置文件,,,,因为简单啊...简单就一定有受众,那么复杂的安卓谁写...多搜搜,,,我又不是小白,,,至少也沉浸多年了,,,写代码有点不利索例如

安卓若有需要还要再过一下....原生的安卓...貌似现在发展到flutter 安卓的发展越来偏向于写配置文件,,,这是趋势,,,所有的页面展示都趋向于写配置文件,,,,因为简单啊...简单就一定有受众,那么复杂的安卓谁写...

多搜搜,,,我又不是小白,,,至少也沉浸多年了,,,写代码有点不利索

例如 https://apis.map.qq.com/ws/district/v1/list?key=OXSBZ-U6CAX-4S444-TOQH6-PTNO7-LVF5H

该api将会返回全部城市列表

这里省事,,,直接 使用JQuery

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <head>
        <script src="https://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js">
        </script>
    </head>
</head>
<body>
<select name="" id="selProvince">
    <option>请选择....</option>
</select>
<select name="" id="selCity">
    <option>请选择....</option>
</select>
<select name="" id="selCountry">
    <option>请选择....</option>
</select>
<script>
    let iNum1;
    let iNum2;
    let aProvince = ['湖北','江苏','安徽'];
    let aCity =[['武汉','黄冈','荆门'],['南京','无锡','镇江'],['合肥','安庆','黄山']];
    let aCountry =[[['武汉1','武汉2'],['黄冈1','黄冈2'],['荆门1','荆门2']],[['南京1','南京2'],['无锡1','无锡2'],['镇江1','镇江2']],[['合肥1','合肥2'],['安庆1','安庆2'],['黄山1','黄山2']]];
    $(function () {
        for(let i = 0; i < aProvince.length; i++){
            $("#selProvince").append("<option>" + aProvince[i] + "</option>");
        }
        $('#selProvince').change(function () {
            // 移除子节点
            $("#selCity").children().not(":eq(0)").remove();
            // 获得位置
            iNum1 = $(this).children("option:selected").index();
            // 进行添加
            for(let i = 0; i < aProvince.length; i++){
                $("#selCity").append("<option>" + aCity[iNum1 - 1][i] + "</option>");
            }
        })
    });
</script>
</body>
</html>

以上所述就是小编给大家介绍的《三级联动》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

A Philosophy of Software Design

A Philosophy of Software Design

John Ousterhout / Yaknyam Press / 2018-4-6 / GBP 14.21

This book addresses the topic of software design: how to decompose complex software systems into modules (such as classes and methods) that can be implemented relatively independently. The book first ......一起来看看 《A Philosophy of Software Design》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具