여기가 바로 지금 거기에 있습니다. 아주 거의 거기에 있습니다. 그러나 숫자를 반올림하는 쉬운 방법이 있습니까?
<!DOCTYPE html>
<html>
<head>
<script src="scripts/jquery-1.3.2.min.js"></script>
</head>
<body>
<input type='text' id='aspectratio' />
<input type='text' id='width' />
X
<input type='text' id='height' />
<div></div>
<script>
$('#width').keyup(function(){
var aspectratio = $('#aspectratio').val();
var width = $(this).val();
var height = aspectratio * width;
$('#height').val(height);
});
$('#height').keyup(function(){
var aspectratio = $('#aspectratio').val();
var height = $(this).val();
var width = aspectratio/height;
$('#width').val(width);
});
</script>
</body>
</html>
fantastic..i는 매우 빨리 시도 할 것입니다. 내가 어떻게 시작하는지 알려주세요. :)) ... $ (this) .val() ..이 (가) 있습니다. 이게 기능이야? 이 작업을 수행하려면이 변경해야합니까 또는이 기능을 추출 할 수 있습니다 ..? – kalabo
$ (this) .val()은 해당 요소에 대한 이벤트 핸들러 (.focusout()) 안에 있기 때문에 $ ('# widthBoxId')의 현재 값을 참조합니다. – jay