Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Full Page Background Image | jQuery Problem in IE7 and 8 Re: Full Page Background Image | jQuery Problem in IE7 and 8

#105030

You are re-using ID values on key elements. You should avoid this and use classes instead when you have multiple elements that should share a handler. I see that you’re doing this with #bks specifically, which is the element jQuery tries to manipulate. This will definitely cause problems with jQuery’s access to those elements.

You could avoid using the id values altogether and reduce your code a bit:

$(function() {
$(window).on("resize", function(){
var self = $(this);
$(".slide > img").prop("class", function(){
return self.width() > self.height() ? "bgwidth" : "bgheight" ;
});
}).trigger("resize");
});‚Äč

I would also encourage you to run your code through a validator and cleanup any errors it reports. I passed your front page through the w3 validator and it turned up 9 errors I believe.