0

ユーザーがテキストボックスに入力し、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" />

更新 タイプミスを修正しましたが、それでも機能しません。

4

2 に答える 2

2

タイプミスがあります:

$(this).css("background-image", "none");

それが問題でない場合は、プラグインの外でこれを参照する必要があるかもしれません:

$(document).ready(function () {
    $("[NeedSpellCheck='true']").each(function () {
        $(this).keypress(function (e) {
            var $this = $(this);  // you could use $this for the following as well
            $(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");  // reference object
                console.log("removed"); //<-- displayed in console
            });
        });
    });
});
于 2012-06-12T21:53:59.883 に答える
0

交換:

$(this).css("backbround-image", "none");

と:

$(this).css("background-image", "none");
于 2012-06-12T21:54:55.517 に答える