jquery - How can I use JavaScript to limit a number between a min/max value? -


i want limit number between 2 values, know in php can this:

$number = min(max(intval($number), 1), 20); // make $number 1 if it's lower 1, , 20 if it's higher 20 

how can in javascript, without having write multiple if statements , stuff that? thanks.

like

var number = math.min(math.max(parseint(number), 1), 20); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -