Tuesday, January 26, 2010

Re: [jQuery] Removing percentage after dot - font-size: 30.6207px

Mircea wrote:
> I have a slider that sets my CSS font-size to a value. The value
> itself is accepted by CSS buy I would like to remove the decimals
> after the dot.
>
> For example one value is:
> font-size: 30.6207px and it should be font-size: 30px
> or
> font-size: font-size: 44.2759px; and it should be font-size: 44px
>
> The font-size is set my this function:
> $(".ui-selected").css('font-size', maxFont * percentage);
>
> Is there a way I could strip the after dot part?
> Thank you.
>

parseInt(maxFont * percentage,10) should do it.
see: http://www.w3schools.com/jsref/jsref_parseInt.asp

Jonathan

--
Jonathan Vanherpe - Tallieu & Tallieu NV - jonathan@tnt.be

No comments: