Creating dropdown <select>

前端 未结 1 856
轮回少年
轮回少年 2020-12-17 18:48

I am new to jQuery and Javascript. I have to create select->option drop down control with client side jQuery/Javascripting. These drop downs are having their options from ar

相关标签:
1条回答
  • 2020-12-17 19:23

    This will create the drop downs on the fly:

    function getDropDownList(name, id, optionList) {
        var combo = $("<select></select>").attr("id", id).attr("name", name);
    
        $.each(optionList, function (i, el) {
            combo.append("<option>" + el + "</option>");
        });
    
        return combo;
        // OR
        $("#SELECTOR").append(combo);
    }
    
    0 讨论(0)
提交回复
热议问题