我正在创建一个页面,设置了两个属性,然后尝试在页面加载后引用这些属性。我已经成功地设置了这些属性,也可以在credit和debit属性中硬编码引用它们。但是动态调用它们并不起作用。欢迎提供建议。
<div class="net" credit="" debit=""></div>
$(document).ready(function() {
... some fancy code involving arrays and junk ...
if(TYPE == 'credit') {
$(".net").attr('credit',data.response.stats.total);
} else if (TYPE = 'debit') {
$(".net").attr('debit',data.response.stats.total);
}
});
$(window).bind("load", function() {
afterPageLoad();
});
function afterPageLoad(){
total_credit = $(".net").attr('credit');
total_debit = $(".net").attr('debit');
total = (total_credit - total_debit);
$(".net").html( "$"+total );
}
parseFloat();
。 - Shawn G.