- 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;
4 RĂ©ponses
+ 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";
+ 3
Well I suggest that that should be done with css so to do that just
element.style = "there put your declaration';
+ 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
+ 2
Thank you đ