zoukankan      html  css  js  c++  java
  • jq的select

    <select id="bank" style="70.5%;height:30px;" onchange="changeBank(value)">
    </select>
    <input type="text" id="account" value="" readonly style="70%;height:25px;" />
    tempAry = msg.row_data.record.cus_bank;
                    if(tempAry.length > 0){
                        $.each(tempAry, function (index, item) {
                            $("<option></option>").val(item.ID).text(item.Bank).appendTo($("#bank"));
                        });
                        $("#account").val(tempAry[0].Account);
                    }else{
                        $("#bank").val("暂无");
                        $("#account").val("暂无");
                    }

    var tempAry=[]全局,请求成功后遍历数组,用链式写法将value和文字注入到新增的option,下面的account做联动

    function changeBank(value){
        $.each(tempAry, function (index, item) {
            if(item.ID == value){
                $("#account").val(item.Account);
                return false
            }
        });
    }

    change做选择事件

    $("#bank").val();
    $("#bank option:selected").text();
    $("#bank").empty();

    获取被选中的value和文本,清除所有option

  • 相关阅读:
    其它运算符
    位运算符
    赋值运算符
    逻辑运算符
    关系运算符
    理解twisted中的reactor和deferred(一)
    修改 Django Administration
    celery 调用scrapy
    flower 时区设置
    Python 过滤HTML实体符号简易方法
  • 原文地址:https://www.cnblogs.com/liufeiran/p/12800761.html
Copyright © 2011-2022 走看看