zoukankan      html  css  js  c++  java
  • jquery 二级联动

    <tr>
    <td class="tdwidth">城市:</td>
    <td><select id="province" name="" style="175px;height:26px;" onchange="fuc()" >
    
    </select> &nbsp;
    <select id="city" name="" style="175px;height:26px;"> 
    </select> </td>
    
    </tr>
    
    <script type="text/javascript">
    $(document).ready(function () {
    htmlobj = $.ajax({ url: "../img/json.js", async: false });
    $.each(jQuery.parseJSON(htmlobj.responseText), function (index, content) { 
    $("#province").append($("<option value="" + content.name + "">" + content.name + "</option>")); 
    });
    $("#city").append($("<option value="1">请选择</option>"));
    });
    function fuc() {
    htmlobj = $.ajax({ url: "../img/json.js", async: false });
    $("#city").html("");
    $.each(jQuery.parseJSON(htmlobj.responseText), function (index, content) {
    if (content.name == $("#province").val()) {
    $.each(content.sub, function (i, contex) {
    $("#city").append($("<option value="" + contex.name + "">" + contex.name + "</option>"));
    });
    }
    });
    } 
    </script>
  • 相关阅读:
    洛谷P1199三国游戏
    Cracking the Coding Interview 6.2
    Cracking the Coding Interview 5.2
    Cracking the Coding Interview 5.7
    洗牌算法
    字符串排列组合问题
    指针作为形参
    KMP算法代码
    搜索二叉树
    面试题集锦
  • 原文地址:https://www.cnblogs.com/lushixiong/p/6685555.html
Copyright © 2011-2022 走看看