我有这个代码:
function EnableiPad(event) {
var id = $(event.currentTarget).attr("data-id");
var status = $(event.currentTarget).attr("data-status");
$.post("/Ipad/ChangeStatus", { id: id, enable: status }, onAjaxSuccess);
};
function onAjaxSuccess(data) {
var status = $(".button-enable").attr("data-status");
if (status == 'true')
{
$('#statusImg').attr("src", '/Content/img/disable.png');
}
else
{
$('#statusImg').attr("src", '/Content/img/enable.png');
}
}
但它不会改变形象 -$('#statusImg').attr("src", '/Content/img/disable.png');
更新
这是我的图片:
@if (iPad.Enabled)
{
<button class="button-enable" data-original-title="Show timetable" data-id="@iPad.Id" data-status="false" class="btn btn-mini" style="border: 0; background: transparent; box-shadow: none; padding: 0;">
<img id="status" width="24" height="24" alt="Delete doctor" src="/Content/img/enable.png" />
</button>
}
else
{
<button id="statusDisable" class="button-enable" data-original-title="Show timetable" data-id="@iPad.Id" data-status="true" class="btn btn-mini" style="border: 0; background: transparent; box-shadow: none; padding: 0;">
<img id="status" width="24" height="24" alt="Delete doctor" src="/Content/img/disable.png" />
</button>
}