jQuery dynamic image laden

**Ich versuche, ein Bild zu laden geben, wenn ich einen Verweis in ein input.

<!DOCTYPE html>
<html>

    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $('#id').focus();
                $('#id').keyup(function () {
                    $('#img').html('<img src="http://www.site.com/' + $(this).val() + '.jpg"
    width="200px">');
                    $('#img').hide().fadeIn('slow');
                });
            });
        </script>
    </head>

    <body>
        <input type="text" size="7" maxlength="7" id="id">
        <div id="img"></div>
    </body>

</html>

Dem fadeIn() nicht funktioniert, außer wenn das Bild bereits im cache. Wie kann ich ein fadeIn jedes mal? Danke im Voraus.

BEARBEITEN

Einem anderen script, es funktioniert!

<!DOCTYPE html>
<html>

    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $('#id').focus();
                $('#id').keyup(function () {
                    $('#img').attr('src', 'http://www.site.com/' + $(this).val() + '.jpg');
                    $('#img').hide();
                });
                $('#img').load(function () {
                    $('#img').fadeIn('slow');
                });
            });
        </script>
    </head>

    <body>
        <input type="text" size="7" maxlength="7" id="id">
        <br>
        <img id="img" width="200px">
    </body>

</html>
Die fadeIn funktioniert, die Sie gerade nicht geben ihn etwas ZU fade, weil das Bild nicht geladen noch. Sie brauchen, um pre-load das Bild.
Ich sehe nicht ein problem mit ihm: jsfiddle.net/JTJKd/2
Ich denke, es gibt kein problem mit Google Bilder, da Sie sehr klein sind.

InformationsquelleAutor Kernel | 2013-08-29

Schreibe einen Kommentar