Home  >  Article  >  Web Front-end  >  How to round jquery value

How to round jquery value

藏色散人
藏色散人Original
2020-11-17 10:26:254310browse

Jquery value rounding method: 1. Rounding up is achieved through the "Math.ceil(a);" method; 2. Rounding down is achieved through the "Math.floor(a)" method; 3. Use the "Math.round(7/2);" method to achieve rounding.

How to round jquery value

The operating environment of this tutorial: windows10 system, jquery2.2.4, this article is applicable to all brands of computers.

Recommended: "javascript basic tutorial"

JQ rounding up and rounding down

Rounding up

var a = 23.2325236
 
var abc = Math.ceil(a); //注意:Math.ceil(a)不要单独写一行,否则向上取整失败
 
abc = 24;

Round down

var a = 23.2325236
 
var abc = Math.floor(a)//注意: Math.floor(a) 不要单独写一行,否则向下取整失败
 
abc = 23;

Round up

Math.round(7/2);

The above is the detailed content of How to round jquery value. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn