<input type="number" placeholder="请输入体重" id="patient-weight-input" oninput="changeWidth()">
function changeWidth() {
var testLength = document.getElementById('patient-weight-input').value.length;
var testDom = document.getElementById('patient-weight-input');
if(Number(testDom.value)>250){
testDom.value=250
}
if(testLength){
$("#patient-kg").show();
if(testLength<4){
testDom.style.width = testLength*0.24 + 'rem';
}
}else{
$("#patient-kg").hide();
testDom.style.width='100%';
}
}
网友评论