我对javascript计算有一个小问题。我有这样的功能:
$( "#main-nav li[class]" ).each(function( index ) {
var position = $(this).offset();
var width = $(this).width();
var center = parseInt(position) - (parseInt(width) / 2);
console.log("Position: " + position.left + ", width: " + width + ", center: " + center);
});
但它导致了这一点。任何人都知道如何不进行计算?
Position: 722, width: 83, center: NaN