【问题标题】:Jquery Plugin Cashregister IssueJquery 插件收银机问题
【发布时间】:2012-09-24 20:58:54
【问题描述】:

有人建议我试试这个简单的jQuery Plugin 给号码一个收银效果

首先我想在jsfiiddle 中进行测试,看看它是如何工作的,但出现了问题 因为我没有任何效果。我对该插件所做的唯一修改如下:

 easing: 'swing',
duration: 1700,

而不是

        easing: 'linear',
        duration: 700,

我不明白我做错了什么,或者插件有问题?

【问题讨论】:

  • 似乎有点坏了。调试看看发生了什么。不知道网上有没有插件的示例用法?
  • 这就是问题所在,没有示例可以查看,Github 中这个插件的文档真的很差
  • 我从不使用 jquery 插件,除非我在网上看到一个工作示例。太多糟糕的,无法正常工作的插件。
  • 你要什么样的收银效果?
  • 换句话说,你能准确解释你想要得到什么吗?如果您只是在寻找一种货币格式... javascript 本身就很容易做到这一点。

标签: jquery jquery-plugins plugins


【解决方案1】:

它根本不适合你,因为你没有正确使用函数参数。

但是即使你做对了——这个插件很糟糕。效果很差。

试试这个:

http://code.google.com/p/jquery-formatcurrency/

工作示例(我对其进行了测试,效果很好)

http://www.bendewey.com/code/formatcurrency/demo/

来源:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>JQuery FormatCurrency Sample</title>
        <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
        <script type="text/javascript" src="jquery.formatCurrency-1.4.0.min.js"></script>
        <style type="text/css">
            body, div  { margin:0px auto; padding:0px; }

            .main { margin:40px; }

            .sample { float:left; margin:10px; padding:4px; border:1px solid #888; width:350px; }

            .sample h3 { margin:-4px; margin-bottom:10px; padding:4px; background:#555; color:#eee; }

            .currencyLabel { display:block; }        
        </style>
        <script type="text/javascript">
            // Sample 1
            $(document).ready(function()
            {
                $('#currencyButton').click(function()
                {
                    $('#currencyField').formatCurrency();
                    $('#currencyField').formatCurrency('.currencyLabel');
                });
            });

            // Sample 2
            $(document).ready(function()
            {
                $('.currency').blur(function()
                {
                    $('.currency').formatCurrency();
                });
            });
        </script>
    </head>
<body>
    <div class="main">
        <div class="formPage">
            <h1>Format Currency Sample</h1>

            <div class="sample">
                <h3>Formatting Using Button Click</h3>
                <input type="textbox" id="currencyField" value="$1,220.00" />
                <input type="button" id="currencyButton" value="Convert" />

                <div>
                    Formatting Currency to an Html Span tag.
                    <span class="currencyLabel">$1,220.00</span>
                </div>
            </div>

            <div class="sample">
                <h3>Formatting Using Blur (Lost Focus)</h3>

                <input type="textbox" id="currencyField" class='currency' value="$1,220.00" />
            </div>

        </div>
    </div>
</body>
</html>

【讨论】:

  • 是的,我在这里尝试...看看,我没有得到 div 中的数字 :( jsfiddle.net/z2qps/16 感谢您的时间
  • 我以为插件可以工作,但不,在我编辑后它甚至没有格式化正确的美元金额!!!请改用我在编辑后的答案中提供的 google-code 插件。
  • 是的,它正在工作,感谢您的出色工作,只是最后一个问题,如果我将数字放在 div 而不是这里 $(document).ready(function( ) { $('#cash').cashRegister(1000000); }); 不做收银效果?看jsfiddle.net/z2qps/17
猜你喜欢
  • 1970-01-01
  • 2018-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多