所以我有一个按钮来添加更多使用jquery完成的下拉框,这里是创建新框的功能
$(document).ready(function() {
var MaxSelects = 7; //maximum input boxes allowed
var SelectsWrapper = $("#SelectsWrapper"); //Input boxes wrapper ID
var AdicionarButton = $("#AdicionarFileBox"); //Add button ID
var x = SelectsWrapper.length; //initlal text box count
var FieldCount=1; //to keep track of text box added
$(AdicionarButton).click(function (e) //on add input button click
{
if(x <= MaxSelects) //max input box allowed
{
FieldCount++; //text box added increment
//add input box
$(SelectsWrapper).append('<div class="selectAplic"><select name="aplicacaoPretendida" id="aplicacoes" class="col_11"></select><a class="removeclass" href="#"><i class="icon-remove"></i></a></div>');
x++; //text box increment
}
return false;
});
然而,当我把我的foreach放进去没有任何事情发生时,该框被创建但内容为空。
@foreach(var row in selectedData){
foreach(var item in row.aplicacoes.ToString().Split(new [] {','})){
<option>@item</option>
}
}
这是我的代码:
<div id="SelectsWrapper" class="col_8">
<div class="selectAplic">
<select name="aplicacaoPretendida" id="aplicacoes" class="col_11" onchange='userExemplo()'>
@foreach(var row in selectedData){
foreach(var item in row.aplicacoes.ToString().Split(new [] {','})){
<option>@item</option>
}
}
</select>
</div>
</div>
现在我如何在mt jquery中添加foreach?