Preload background | SoloLearn: Learn to code for FREE!

+1

Preload background

I have a preloaded image in an image variable: var a=new Image() After that I can use the variable for drawing image: ctx.drawImage(a,x,y) But how can I change a background of TD using this variable and JQuery ? Is it possible ?

11/27/2018 9:11:48 AM

Алексей Васильев

6 Answers

New Answer

+4

Perhaps create a CSS class instead, with a setting for background image, and then toggle the class in the <td> where you want? CSS class can be implemented to multiple <td> anyways : )

+3

To be honest I only know preloaded images can be used for <img>, I never tried it for <td> background image, you meant a <td> of a <table> here? or am I misunderstanding you ...

+3

Do you have that code here in your profile? can you attach the code URL on the original post, that way I hope others who knows better can help you with it. In the meantime I will try to search for a feasible solution.

+1

Yes, for td in table. I try to work with images correctly but I don't know how.

+1

My images are not in the same directory. They are far and I run the risk of trying to change the background BEFORE the image was loaded...

+1

I will prepare it thank you)