Discussion:
How to check TD background image has been loaded.
ace jquery
2010-02-25 18:11:30 UTC
Permalink
Hi there,

I am trying to update the attr of background in <td>. ==>> <td id="mytd"
background="" height="100%" align="left" valign="top"></td>

is that possibly to use jQuery to check if the background image has been
loaded?

something like this..

$('#mytd background').load(function(){
alert('the background image has been loaded');
});

Thank you for you help!
-Ace
jscharf
2010-02-26 12:12:28 UTC
Permalink
2 possibilities:

via attribute:
$("#mytd").attr("background", "path/to/image.jpg");

or via CSS
$("#mytd").css("background-image", "path/to/image.jpg");

that should work fine for your needs (make sure the paths are correct)
Liam Byrne
2010-02-26 13:48:15 UTC
Permalink
That won't trigger a load event

This is as close as you'll get (using an image object to actually load
it, and then using it.

var imageObj = new Image();
$(imageObj).attr("src",imagePath).load(function(){
// do whatever else you want to do in here too
$("#leftCol").css("background-image","url("+imagePath+")");});

Liam
Post by jscharf
$("#mytd").attr("background", "path/to/image.jpg");
or via CSS
$("#mytd").css("background-image", "path/to/image.jpg");
that should work fine for your needs (make sure the paths are correct)
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.733 / Virus Database: 271.1.1/2709 - Release Date: 02/25/10 07:34:00
Continue reading on narkive:
Loading...