
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to set the width of an element's border with JavaScript?
To set the width of an element’s border in JavaScript, use the borderWidth property. Set the width using this property.
You can try to run the following code to learn how to set the width of an element’s border −
Example
Live Demo<!DOCTYPE html> <html> <head> <style> #box { border: thick solid gray; width: 300px; height: 200px } </style> </head> <body> <div id = "box">Demo Text</div> <br> <br> <button type = "button" onclick = "display()">Change border width</button> <script> function display() { document.getElementById("box").style.borderWidth = "thin"; } </script> </body> </html>
- Related Articles
- How to set the style of an element's border with JavaScript?
- How to set the maximum width of an element with JavaScript?
- How to set the minimum width of an element with JavaScript?
- How to set the width of the right border with JavaScript?
- How to set the width of the left border with JavaScript?
- How to set the width of the bottom border with JavaScript?
- How to set the width of the top border with JavaScript?
- How to set the width of the outline around an element with JavaScript?
- How to set the width of an element in JavaScript?
- How to set border width, border style, and border color in one declaration with JavaScript?
- Set border width with CSS
- How to set an element's display type with JavaScript?
- Set the width of image border with CSS
- How to set the color of an elements border with JavaScript?
- Set the border image width with CSS

Advertisements