jQuery语法:在何处放置"toFixed" [英] jquery syntax : where to put "toFixed"

查看:109
本文介绍了jQuery语法:在何处放置"toFixed"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想舍入以下jQuery的结果,但我不知道将.toFixed()

I want to round the result of following jQuery but I don't know where to put .toFixed()

    (function ($) {
        $(document).ready(function() {
            $('#custom_coverage').keyup(function() {
                $('#result').text($('.reads').text() / ($('.amplicons').text() * $('#custom_coverage').val()));
            });    
        });
    }(jQuery));

谁可以提供帮助?

推荐答案

尝试一下

 (function ($) {
     $(document).ready(function () {
         $('#custom_coverage').keyup(function () {
             var raw = $('.reads').text() / ($('.amplicons').text() * $('#custom_coverage').val());
             var fixed = raw.toFixed(2);
             $('#result').text(fixed);
         });
     });
 }(jQuery));

这篇关于jQuery语法:在何处放置"toFixed"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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