当用户在文本框中键入时,我正在显示一个旋转的轮子图像,并且在完成 ajax 调用后,我想删除该图像。问题是图像不会消失。我确定代码已执行,因为我可以看到代码中所述的日志信息。我究竟做错了什么?
$(document).ready(function () {
$("[NeedSpellCheck='true']").each(function () {
$(this).keypress(function (e) {
$(this).css("background-image", "url(images/loading.gif)");
$(this).css("background-repeat", "no-repeat");
$(this).css("background-position", "right");
$(this).spellchecker(
{
url: "~/JQuerySpellCheckerHandler.ashx",
lang: "en",
engine: "google",
suggestBoxPosition: "bottom"
}).spellchecker("check", function (result) {
$(this).css("background-image", "none"); // <-- corrected typo
console.log("removed"); //<-- displayed in console
});
});
});
});
<input type="text" NeedSpellCheck="true" />
更新 我纠正了错字,但它仍然不起作用。