get CSS rule's percentage value in jQuery

后端 未结 12 1341
一个人的身影
一个人的身影 2020-11-22 08:22

Let\'s say the rule is as follows:

.largeField {
    width: 65%;
}

Is there a way to get \'65%\' back somehow, and not the pixel value?

12条回答
  •  伪装坚强ぢ
    2020-11-22 08:48

    Late, but for newer users, try this if the css style contains a percentage:

    $element.prop('style')['width'];
    

提交回复
热议问题