I have multiple inputs that each one has an increment and decrement button
The buttons will be pressed multiple times so I am looking to optimize my selector:
So should I keep the first one (which selects by attribute) or the second? Or anything more optimized.
$("[data-id-col="+thisID+"]")
$("input:tel#"+thisID+")
$("body").on('click','.incButton',e=>{
let thisID = e.currentTarget.getAttribute("d-id");
let colInput = $("[data-id-col="+thisID+"]");
colInput.val( parseInt( colInput.val())+1);
colInput.change();
});
HTML:
Input
<div class="handle-counter" id="handleCounter3">
<input type="tel" data-id-col="8900" id="qty_inputCol" class="qty_col">
</div>
Button
<button type="button" d-id="8888" class="btn btn-primary btn-block inc"></button>