获取x的某位数字,d=1即获取个位数,d=2即获取百位数..

   function getDigit(x,d){
     return parseInt((x/Math.pow(10,d-1))%10);
   }