jQuery CSS borderWidth

后端 未结 3 1734
谎友^
谎友^ 2020-12-20 19:24

I\'m unable to get the border width of an element. I tried the following but it shows empty results. Check http://jsfiddle.net/s7YAN/14/

$(\'div\').css(\'bor         


        
3条回答
  •  再見小時候
    2020-12-20 19:50

    For border-width, you need to specify the side of the border. borderWidth/border-width is a shortcut for all of the border-width's at once.

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

    http://jsfiddle.net/ZsSmp/

    Also, you need to specify more than a border width for it to be valid. Just specifying a border-width does not make a border. It needs a color and style, too:

    border: 2px solid black;
    

提交回复
热议问题