我有以下类,它选择 td.lineitemtotal 单元格内部的内容,并在 getTotal 函数中使用它来获取单元格总数。但是,我不希望该函数使用 tr.line_item_row 中带有 style="display:none;"的行属性。
$(document).ready(function() {
var line = $('.item');
// so the line totals are calculated on page load
getLineItemTotals(line);
var line_totals = $('.lineitemtotal');
getTotal(line_totals); // So the total is calculated on page load.
});
// get invoce grand total
function getTotal(lines) {
var total = 0;
$.each(lines, function(){
total += parseFloat($(this).html());
});
$('#total-price').html('$' + total.toFixed(2));
}
最佳答案
你想要这个吗?
$('.lineitemtotal:visible');
此集合包含具有 lineitemtotal
类的非隐藏元素。
关于javascript - 查询。选择具有类但没有样式 ="display:none;"属性的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12517476/