輸入標籤值我有一個div更新錨標籤點擊
@{int index = 0;}
@for (int i = 0; i < Model.lstFiles.Count; i++)
{
<div id="attachmentDetail(@index)" name="attachmentDetail(@index)" class="panel-body">
<a asp-action="Download" asp-controller="Admin" asp-route-realName=Model.lstFiles[i].RealName>@Model.lstFiles[i].FileName</a>
<a onclick="btnDelFile_Click(@index)" id="btnDelFile{@index}" class="pull-right" title="delete"><img height="20" width="20" src="@Url.Content("~/images/delete.jpg")" /></a>
<input type="text" asp-for="@Model.lstFiles[i].IsDeleted" hidden />
<input type="text" asp-for="@Model.lstFiles[i].FileId" hidden />
<hr />
</div>
index++;
}
我要更新btnDelFile_Click
@Model.lstFiles[i].IsDeleted
值。但我無法獲得div和它的孩子。我想這個代碼
$('#attachmentDetail(' + index +') :input lstFiles['+index+'].IsDeleted').val("True");
但它說
jquery.min.js:2 Uncaught Error: Syntax error, unrecognized expression: #attachmentDetail(0)
有沒有更好的辦法讓DIV的孩子?我想更新IsDeleted
的值,然後隱藏這個div。
任何形式的幫助將不勝感激。
工作就像一個魅力。謝謝 :) –