$(document).ready( () => { console.log('Load component - buy') const component = $('.component-buy') if(component.length) { const details = component.find('.details') if(details.length) { const qty = details.find('.qty') const plus = details.find('.plus') const minus = details.find('.minus') qty.on('input', (e) => { $(e.currentTarget).val($(e.currentTarget).val().replace(/[^0-9]/g, '') || 1) }) plus.off('.click').on('click.click', () => { const value = parseInt(qty.val()) qty.val(value + 1) }) minus.off('.click').on('click.click', () => { const value = parseInt(qty.val()) if(value > 1) { qty.val(value - 1) } }) } } })