- 1

How can I use box-shadow with JavaScript

How can I use box-shadow with JavaScript Using style. For example I can do element.style.top = 10px;

1st Sep 2022, 8:07 PM
Elijah Adebanwo
Elijah Adebanwo - avatar
4 Antworten
+ 5
You can use 👇 object.style.boxShadow = "value"; For example : HTML ➡️ <div id="shadow">This Box has box-shadow</div> JavaScript ➡️ document.getElementById("shadow").style.boxShadow = "5px 10px #888";
2nd Sep 2022, 6:03 AM
Sujal
Sujal - avatar
+ 3
Well I suggest that that should be done with css so to do that just element.style = "there put your declaration';
1st Sep 2022, 8:30 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
+ 3
Using js to style is not good practice, if code is long it gets hard to change or debug style. You can append class name or id with js and keep all styles inside css, if you need to change you can easier find thing you need. Here is how you can set box shadow with pure js, without using class/id, but I still suggest you to use this in your codes. https://www.w3schools.com/jsref/prop_style_boxshadow.asp And how to append class name using js: https://www.w3schools.com/howto/howto_js_add_class.asp
1st Sep 2022, 10:43 PM
PanicS
PanicS - avatar
+ 2
Thank you 😊
2nd Sep 2022, 8:24 AM
Elijah Adebanwo
Elijah Adebanwo - avatar