How to attach one or more drop-shadows to the box with JavaScript?

HTMLJavascriptProgramming Scripts

To attach drop-shadows to the box, use the boxShadow property in JavaScript. With this property, add the width of the shadow as well as color.


You can try to run the following code to learn how to attach one or more drop-shadows.

Live Demo

<!DOCTYPE html>
         #box {
            border: thick solid green;
            width: 300px;
            height: 200px
      <div id="box">Demo Text</div>
      <button type="button" onclick="display()">Add drop shadow</button>
         function display() {
            document.getElementById("box").style.boxShadow = "20px 15px 25px orange";
Published on 26-Feb-2018 15:49:48