Convert css width string to regular number

后端 未结 5 820
闹比i
闹比i 2020-12-15 18:11

While trying to compute the width of an hidden element I found that jquery.width() returns 0 for that elements\' width.

I found out that using jquery.css(\'width\'

5条回答
  •  星月不相逢
    2020-12-15 18:29

    In plain JavaScript:

    parseInt('100px', 10)
    

    Works with "100em", "100%", and even with: "100". No need for any Regular Expression patterns.

提交回复
热议问题