• 회원가입
  • 로그인
  • 구글아이디로 로그인

[Math] JS - Math.floor() 메서드 ★ - 하향반올림 (= 아래로 반올림 = 플로메서드 = floor메서드) ※무조건 천단위 입력만 허용

floor() 예제

 

<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  document.getElementById("demo").innerHTML = Math.floor(1.6);

}

</script>

 

결과보기

결과값: 1

 

floor() 예제 - 무조건 천단위 입력

 

<script src="http://code.jquery.com/jquery-latest.js"></script>


<input type="text" id="hz">

<script>

$(function() {

  $('#hz').on('change', function() {

     var n = $(this).val(); 

     n = Math.floor(n/1000) * 1000; 

     //alert(n);  

     $(this).val(n);

  });

});

</script>

 

트샷 님 https://sir.kr/qa/242557

 

방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
Math JS - Math 객체 (속성 + 메서드) 종류
Math JS - Math.E 속성 - 오일러값 (= 오일러수 = 오일러상수)
Math JS - Math.LN2 - 2의 자연로그값
Math JS - Math.LN10 - 10의 자연로그값
Math JS - Math.LOG2E - 밑이 2인 오일러로그값
Math JS - Math.LOG10E - 밑이 10인 오일러로그값
Math JS - Math.PI - 원주율 (= 파이)
Math JS - Math.SQRT1_2 - 1/2의 제곱근값
Math JS - Math.SQRT2 - 2의 제곱근값
Math JS - Math.abs() 메서드 ★ - 절대값 반환 (= Math.abs메서드 = 매스앱스메서드)
Math JS - Math.acos() 메서드 - 아크코사인값
Math JS - Math.asin() 메서드 - 아크사인값
Math JS - Math.atan() 메서드 - 아크탄젠트값
Math JS - Math.atan2() 메서드 - 아크탄젠트2값
Math JS - Math.ceil() 메서드 ★ - 상향 반올림 (= 위로 반올림 = 씰)
Math JS - Math.cos() 메서드 - 코사인값
Math JS - Math.exp() 메서드 - 오일러승수 (= 로그역함수 = exp메서드)
Math JS - Math.floor() 메서드 ★ - 하향반올림 (= 아래로 반올림 = 플로메서드 = floor메서…
Math JS - Math.log() 메서드 - 로그값
Math JS - Math.max() 메서드 ★ - 최대값 (= 최댓값 = Math.max메서드 = 매스맥스메서드)
1/3
목록
찾아주셔서 감사합니다. Since 2012