How can I get the font size of an element as it was set by css

后端 未结 4 1643
慢半拍i
慢半拍i 2020-12-09 20:10

I\'m writing a simple jQuery that to change the font size of an element by a certain percentage. The problem I\'m having is that when I get the size with jQuery\'s $(\'#el\'

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 20:40

    i had this problem once. i use this function to get the int value of a css attribute, if there is one.

    function PBMtoInt(str)
    { 
    return parseInt(str.replace(/([^0-9\.\-])+/,"")!=""?str.replace(/([^0-9\.\-])+/,""):"0");
    }
    

提交回复
热议问题