我有一個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
總是最小的錯誤,謝謝! – Veltar
發生錯誤。沒有問題! :) –