Assigned width in percentage but want to get it in pixels

前端 未结 11 1234
北荒
北荒 2020-12-15 15:07



        
11条回答
  •  难免孤独
    2020-12-15 15:30

    One of options can be too, that parent element is not visible. Here is example: http://jsfiddle.net/nDMM3/

    You can see, that jQuery return width = 100 (like 100%)

    .test {
        border: 1px solid;
        cursor: pointer;
        height: 10px;
        position: relative;
        width: 100%;
        display:none;
    }
    
    #test2{
       width:100%;
    }
    
    
    Hello
    alert($('#test2').width());

提交回复
热议问题