Hey guys, I'm currently learning jQuery, and I am curious about something.
For functions that return sizes in strings, like say:
$(".some-class").css("line-height"); // => "18px"
Is there a way to compare them? For example, if I want to see if it's at least a certain size before doing something?
I'm not actually planning on using this, I'm just curious. I searched around but I didn't find anything. I imagine a plugin would have been written. Perhaps first making sure the comparative string is of the same units of measurement, then seeing which is the bigger number, or something like that.
As a side question, out of curiosity: in javascript, what would be the way to preserve only the number? So, how would I go about getting just 18
or "18"
from "18px"
? If, for fun/practice, I wanted to implement what I stated above, are there any methods I should take a look at, to split the number from the rest, or should I simply use regular expressions?