js 动态更新option

var sel = document.getElementById("MsgTmpId");
                    $("#TmpId").find("option").remove();
                    $.each(data.Data, function (index, item) {
                        var opt = document.createElement("option");
                        opt.innerHTML = item.TemplateName;
                        opt.value = item.Id;               
                        opt.setAttribute("varsList", item.VariableList);
                        opt.setAttribute("templateContent", item.TemplateContent);
                        sel.appendChild(opt);
                    });

 

posted @ 2022-11-09 14:46  LoveMe7788  阅读(139)  评论(0编辑  收藏  举报