New course! Every coder should learn Generative AI!
Try a free lesson- 1
How can I change background with oninput ?
I want to change background image url in css <style> tag with oninput js function. Can I do? How?
9 Answers
+ 1
Hi ℋℜҜ
document.body.style.backgroundImage = “url(value);
For the image.
Getting a link from the user to the image will be the easiest way to do that without having to put it on a webserver
+ 1
Ollie Q , thanx very much for being with me whenever I got confused.
https://code.sololearn.com/WACjk85D721p/?ref=app
+ 1
Tharul Nejana , Thanx for answering but, this is animation, I want bg image change with oninput.
0
Ollie Q , document.body.style.backgroundImage= url(file:///storage/emulated/0/Download/images%20(14).jpeg);
It is showing error "missing ) after argument list"
0
Ok, so i think you’ve got a link issue which is causing the problem
0
Ollie Q , I am not editing in sololearn. In other app, it is showing when I type the link in src.
0
Ok, then try wrapping the url in ‘’ like i am in this code. That might be causing the issue. Example:
“url(‘VALUE’)”
https://code.sololearn.com/WH9kwX1cDbKb/?ref=app
0
No problem, happy coding!