在我看来,我有一个 dropDownListFor,如下所示:
`@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)
<input type='button' value='Adicionar' onclick='adicionarResponsavel()' class='btn' />`
我需要在用户单击 adicionarResponsavel() 时添加多个 dropDownList。
我的 JavaScript 代码是:
function adicionarResponsavel(){
var div = document.getElementById('listaResponsaveis');
var node = document.createElement('div');
node.setAttribute('id', 'div' + quantity);
node.appendChild('@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)');
div.appendChild(node);
}
有错误的具体行是:
node.appendChild('@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)');