option生成

 function loadclass()
    {
        jQuery.ajax({
            url: "/Assets/GetDistinctClassNameByType",
            data: { typeid: $("#DDLTypeID").val() },
            type: "post",
            cache: false,
            dataType: "json",
            success: function(msg) {
            var select_root = document.getElementById('DDLAssetsName');
            select_root.options.length = 0;
            select_root.add(new Option("请选择", '-1'));
                var data = msg.options;
                $.each(data, function(i, n) {
                    if(n.text&&n.value)
                    {
                    var option = new Option(n.text, n.value);
                    select_root.add(option);
                    }
                });
            }
        });
        var select_root = document.getElementById('DDLAssetsModel');
            select_root.options.length = 0;
            select_root.add(new Option("请选择", '-1'));
    }
原文地址:https://www.cnblogs.com/soonfly/p/1646619.html