To set the style of an element’s border, use the borderStyle property in JavaScript.
Example
You can try to run the following code set in the style of an element’s border with JavaScript −
<!DOCTYPE html> <html> <head> <style> #newDiv { height: 150px; width: 150px; border: 2px solid #000000; } </style> <body> <div id="newDiv"> Demo Content! </div> <br> <button type="button" onclick="display()">Change border style</button> <script> function display() { document.getElementById("newDiv").style.borderStyle = "dashed"; } </script> </body> </html>