jquery – .load() or .html() Method wont work in Opera 9 – Education Career Blog

javascript/jquery:

$(document).ready(function(){

$("a").click(function(e){

    var nr = $(this).attr("href").substr(2,3);
    var filename = "images/galerie/martina-flatau"+nr+".png";

    e.preventDefault();

    $('#mainview').fadeOut(function() {

        var image = $('<img />').attr('src', filename);       

        image.load(function(){                      
        $('#mainview').html(image).fadeIn();    
        });         

    });     

});

});

Question 1:
Some pics (not all!) wont get loaded in Opera 9..I dont know why?

Question 2:
Is there a way to improve the code (even the slightest bit?)

,

Some pics (not all!) wont get loaded in Opera 9..I dont know why?

This is because you’re setting the load event after specifying the src property. Some images will be loaded before the handler is defined.

Leave a Comment