我有這個頁面jQuery的MVC-3功能的參數
<script type="text/javascript">
$(document).ready(function() {
$("#delete").click(function() {
if (confirm) {
$("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/")');
}
else {
return false;
}
});
});
</script>
<table>
<tr>
<td>Description</td>
<td>Schedule</td>
<td> </td>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Description</td>
<td>@item.Schedule</td>
<td><a href="@Url.Action("ScheduleEdit", new { @id = item.Id })" class="popLink"><img alt="" src="@Url.Content("~/Content/images/icons/edit.gif")" style="border:none;" /></a>
<img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" id="delete" /></td>
</tr>
}
</table>
jQuery的功能有被使用id =「刪除」的元素,例如,一個img標籤觸發。
有人可以幫我請,我需要有這個jQuery函數有一個參數使用傳遞的onclick例如像
$(document).ready(function() {
$("#delete").click(function (id) {
if (confirm) {
$("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/" + id)');
}
else {
return false;
}
});
});
<img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" onclick="delete(@item.Id)" />
我已經加入ID上的jQuery作爲參數。我試過,但總是有編譯錯誤「身份證不在上下文」的事情。
有人可以幫忙嗎?非常感謝你。
你的圖片有一個JS函數,但你的jQuery被連接到一個ID'刪除'... ID應該是唯一的。創建一個接受參數的函數,並把你的jQuery放在裏面。 – Phill