How can I change background with oninput ? | Sololearn: Learn to code for FREE!
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?

23rd Jun 2021, 3:28 AM
Harsh
Harsh - avatar
9 Answers
23rd Jun 2021, 3:32 PM
Tharul Nejana
Tharul Nejana - avatar
+ 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
23rd Jun 2021, 3:31 AM
Ollie Q
Ollie Q - avatar
+ 1
Ollie Q , thanx very much for being with me whenever I got confused. https://code.sololearn.com/WACjk85D721p/?ref=app
23rd Jun 2021, 1:10 PM
Harsh
Harsh - avatar
+ 1
Tharul Nejana , Thanx for answering but, this is animation, I want bg image change with oninput.
24th Jun 2021, 2:36 AM
Harsh
Harsh - avatar
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"
23rd Jun 2021, 4:04 AM
Harsh
Harsh - avatar
0
Ok, so i think you’ve got a link issue which is causing the problem
23rd Jun 2021, 4:21 AM
Ollie Q
Ollie Q - avatar
0
Ollie Q , I am not editing in sololearn. In other app, it is showing when I type the link in src.
23rd Jun 2021, 4:23 AM
Harsh
Harsh - avatar
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
23rd Jun 2021, 4:32 AM
Ollie Q
Ollie Q - avatar
0
No problem, happy coding!
23rd Jun 2021, 9:35 PM
Ollie Q
Ollie Q - avatar