floor() 예제
<button onclick="homzzang()">클릭</button> <p id="demo"></p> <script> function homzzang() { document.getElementById("demo").innerHTML = Math.floor(1.6); } </script> 결과보기
<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>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<input type="text" id="hz">
$(function() {
$('#hz').on('change', function() {
var n = $(this).val();
n = Math.floor(n/1000) * 1000;
//alert(n);
$(this).val(n);
});
트샷 님 https://sir.kr/qa/242557