Jump to content
GreenSock

GreenSock Docs

getUnit()

Returns : String

Returns unit of a given string where the number comes first, then the unit.


Isolates the unit inside a string where the number is first, then the unit.

  1. // returns the unit of a CSS value
  2. gsap.utils.getUnit("50%"); // "%"
  3. gsap.utils.getUnit("100vw"); // "vw"
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×