+ 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 ?

27th Nov 2018, 9:11 AM
Алексей Васильев
Алексей Васильев - avatar
6 odpowiedzi
+ 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 : )
27th Nov 2018, 10:01 AM
Ipang
+ 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 ...
28th Nov 2018, 4:37 PM
Ipang
+ 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.
28th Nov 2018, 4:50 PM
Ipang
+ 1
Yes, for td in table. I try to work with images correctly but I don't know how.
28th Nov 2018, 4:42 PM
Алексей Васильев
Алексей Васильев - avatar
+ 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...
28th Nov 2018, 4:44 PM
Алексей Васильев
Алексей Васильев - avatar
+ 1
I will prepare it thank you)
28th Nov 2018, 5:32 PM
Алексей Васильев
Алексей Васильев - avatar