i have variable pid (represents parent_id attribute of each li element) "1","14","253",etc. need align content of li left , right.
based on condition, if parent id has number of digits, align left, else align right.
how can find out number of digits in pid variable using javascript?
thanks stopping by.
to number of digits in numeric string in javascript , easiest way can think of use length property of string:
var pid = "123"; var numdigits = pid.length; if(numdigits === parsefloat(numdigits)) { if(numdigits%2 === 0 ) { // } else { // odd } }
Comments
Post a Comment