无法在jquery函数中调用javascript函数

时间:2014-05-16 03:11:12

标签: javascript jquery

我有一个带有以下代码的phtml(magento):

        <? if($discount_amount != ""): ?>
        <script type="text/javascript">

        function memberprice () {

            price_text = jQuery('.price-box .price').text();
            price_num = Number(price_text.replace(/[^0-9\.]+/g,""));
            final_price = price_num - <? echo $discount_amount ?>;

            return '$'+parseFloat(final_price).tofixed(2);

        }
        jQuery('.price-box .price').on("hover", function() {
            new_price = memberprice();
            jQuery('.price-box .price').text(new_price);
        });             

        </script>       
        <? endif ?>

当我悬停.price div时,错误会显示在console memberprice中

Uncaught TypeError: undefined is not a function kelvinator-3-4-kwn07crd-d.html:1635
memberprice kelvinator-3-4-kwn07crd-d.html:1635
(anonymous function) kelvinator-3-4-kwn07crd-d.html:1639
f.event.special.(anonymous function).handle jquery.js:3
f.event.dispatch jquery.js:3
h.handle.i

关于代码的问题是什么?

0 个答案:

没有答案