자바 스크립트 계산에 작은 문제가 있습니다. 나는 다음과 같은 함수를 가지고있다.작은 계산 문제
$("#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
실수가 발생합니다. 문제 없습니다! :) –