Jquery/javascript flash函数用于多个元素

Jquery/javascript flash function for multiple elements

本文关键字:元素 用于 函数 javascript flash Jquery      更新时间:2023-09-26

看看这段代码:

var shipping = $('#shipping_cell');
var total = $('#total_cell');
flash_cell(shipping);
flash_chell(total);
function flash_cell(target){
    var background = target.css('backgroundColor');
    target.stop().css("background-color", "#ac4341").animate({ backgroundColor: background}, 1500);
}

当我运行此代码时,只有#shipping单元格闪烁。

如果我flash_cell(shipping);切换线路并flash_cell(total);,则不会闪烁。

为什么他们都不闪?

编辑 - 这是我的 html

<td id = 'total_cell'><%= view_in_preferred_currency(@order.total) %></td>
<td id = "shipping_cell">
                <% if @order.free_shipping? or @order.collection? %>
                  <%= view_in_preferred_currency(0) %>
                <% else %>
                  <%= view_in_preferred_currency(@order.shipping_option.price) %>
                <% end %>
              </td>

修正拼写错误:

flash_chell(总计)到 flash_cell(总计)