Padding or margin value in pixels as integer using jQuery

后端 未结 14 2208
陌清茗
陌清茗 2020-11-28 02:40

jQuery has height() en width() functions that returns the height or width in pixels as integer...

How can I get a padding or margin value of an element in p

14条回答
  •  心在旅途
    2020-11-28 03:20

    ok just to answer the original question:

    you can get the padding as a usable integer like this:

    var padding = parseInt($("myId").css("padding-top").replace("ems",""));

    If you have defined another measurement like px just replace "ems" with "px". parseInt interprets the stringpart as a wrong value so its important to replace it with ... nothing.

提交回复
热议问题