使用jQuery解析浮点数并舍入小数点 [英] Parse to float and round the decimal point using jQuery

查看:71
本文介绍了使用jQuery解析浮点数并舍入小数点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var imagePos = $("#cursorImage").position();
var topValue=imagePos.top;



我想解析topValue浮动并围绕它的deciaml位置。我曾经使用过Fix()函数,但是它没有使用position()。你能帮帮我吗?



代码块添加[/ edit]


I would like to parse "topValue" to float and round its deciaml Position. I used toFixed() function but it's not working with position(). Could you Please help me?

[edit]Code block added[/edit]

推荐答案

#cursorImage)。position( );
var topValue = imagePos.top;
("#cursorImage").position(); var topValue=imagePos.top;



我想解析topValue浮动并围绕它的deciaml位置。我曾经使用过Fix()函数,但是它没有使用position()。你能帮帮我吗?



添加代码块[/ edit]


I would like to parse "topValue" to float and round its deciaml Position. I used toFixed() function but it's not working with position(). Could you Please help me?

[edit]Code block added[/edit]


var floatvalue = parseFloat(topValue);

var intvalue = Math.round( floatvalue );


这篇关于使用jQuery解析浮点数并舍入小数点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆