JQuery CSS borderWidth

I can not get the border width of the element. I tried the following, but it shows empty results. Check out http://jsfiddle.net/s7YAN/14/

$('div').css('borderWidth'); 
+6
source share
3 answers

borderWidth - syntactic sugar for setting each border width independently. You cannot assume that each border width is the same, so you need to specify a specific border width.

 $("div").css("borderTopWidth"); 
+11
source

For the width of the border you need to specify the side of the border. borderWidth / border-width is a shortcut to all border-width once.

 $( function() { alert($('div').css("border-top-width")); }); 

http://jsfiddle.net/ZsSmp/

In addition, you need to specify more frame widths so that it is valid. Just specifying a width border does not create a border. To do this, you need color and style:

 border: 2px solid black; 
+6
source

The problem is that you are not defining a border style in your CSS, so by default there is none with a width of 0px.

In addition, you must indicate which border (left, top) for border-width is just a shortcut for all borders.

+3
source

Source: https://habr.com/ru/post/887409/


All Articles