<script>
document.addEventListener("DOMContentLoaded", () => {
var el = document.querySelector('#quantity');
el.addEventListener('input', function(){
let val = this.value;
let max = parseFloat(this.getAttribute('max'));
val = parseFloat(val);
if(isNaN(val)) this.value = '';
if(val > max) this.value = max;
});
});
</script>
1条答案
按热度按时间u3r8eeie1#
试试这个