How to set border width using jQuery ? Last Updated : 15 May, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will see how to set the border width using jQuery. To set the border width using jQuery, we will use css() method. This method is used to change the style property of the selected element. Syntax: $(selector).css(property, value) // Or $(selector).css({property: value, property: value, ...}) Where - property is the name of the CSS property, and value is the corresponding property value. Example 1: In this example, we will set the border-width to 5px using css() method. HTML <!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title> How to set border width using jQuery? </title> <script src= "https://code.jquery.com/jquery-3.6.0.min.js"> </script> <style> body { text-align: center; } .GFG { width: 300px; margin: auto; border: 1px solid black; padding: 30px 20px; } button { margin-top: 10px; } </style> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h3> How to set border width using jQuery? </h3> <p class="GFG">Welcome to GeeksforGeeks</p> <button onclick="Func()">Set Border Width</button> <script> function Func() { $('.GFG').css('border-width', '5px'); } </script> </body> </html> Output: Example 2: In this example, we will add multiple border styles using jQuery css() method in property, value format. HTML <!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title> How to set border width using jQuery? </title> <script src= "https://code.jquery.com/jquery-3.6.0.min.js"> </script> <style> body { text-align: center; } .GFG { width: 300px; margin: auto; padding: 30px 20px; } button { margin-top: 10px; } </style> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h3> How to set border width using jQuery? </h3> <p class="GFG">Welcome to GeeksforGeeks</p> <button onclick="Func()">Set Border Width</button> <script> function Func() { $('.GFG').css({ "border-width": "5px", "border-style": "solid", "border-color": "green" }); } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to set border width using jQuery ? V vkash8574 Follow Improve Article Tags : Web Technologies JQuery jQuery-Questions Similar Reads How to Set Border Width in CSS? The CSS border-width property is used to set the border of an element. This property allows you to specify the width of the border for all four sides of an element or individually for each side. Here, we will cover all possible approaches with detailed explanations and code examples. Table of Conten 3 min read How to specify the width of the border image using CSS? In this article, we will set the width of the border image using CSS. To set the width of the border image, we use CSS border-image-width property. The border-image-width property is used to set the width of the border-image. It can be set by providing multiple values. If only one value is provided, 2 min read How to find all textareas and makes a border using jQuery ? In this article, we will find all textareas and makes a border using jQuery. To add a border to the textarea element, we use css() method. The css() method is used to change style property of the selected element. The css() in jQuery can be used in different ways. The css() method can used to check 1 min read How to get inner width (excluding the border) of an element using jQuery ? We can get the inner width of any element using the jQuery innerWidth() method. The innerWidth() method returns the inner width of the first matched element including padding but not border. Syntax: $(selector).innerWidth() So the inner width of an element is shown in the below image. Inner width Th 1 min read CSS border-top-width Property The border-top-width property in CSS is used to set a specific width to the top border of an element. The border-top-style or border-style property is used for the element before using the border-top-width property.Default Value: mediumSyntax: border-top-width: length|thin|medium|thick|initial|inher 2 min read Like