首页 > 扩展 > jQuery > 正文

JQuery常用写法

2024-09-06 20:04:41
字体:
来源:转载
供稿:网友
$(function() {
        //主物资分包编号初始化
        var selectpackages = $("select[name='spackageindex']");
        var hipackages = $("input[name='hipackageindex']");
        var packagecount = $('#<%=txtCount.ClientID %>').attr("value");
        for (var i = 0; i < selectpackages.length; i++) {
            //selectpackages.item(i).options.length = 0;
            for (var m = 1; m <= packagecount; m++) {
                selectpackages[i].options.add(new Option(m, m));
            }
            selectpackages[i].value = hipackages[i].value;
        }
        //子物资分包编号初始化
        var selectpackagesson = $("select.hai");
        var hipackagesson = $("input[name='hipackageindexson']");
        for (var k = 0; k < hipackagesson.length; k++) {
            if (hipackagesson[k].value != "") {
                for (var m = 1; m <= packagecount; m++) {
                    selectpackagesson[k].options.add(new Option(m, m));
                }
                selectpackagesson[k].value = hipackagesson[k].value;
            }
        }
    });

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表