It sure is an unrecognized expression, but how can i fix it?
$('body').on('keydown', 'input[class=form-control amount]', function (e) {
if (e.which === 110 | e.which === 190) {
e.preventDefault();
return false;
}
});
Try this:
$('body').on('keydown', 'input.form-control.amount', function (e) {
if (e.which === 110 | e.which === 190) {
e.preventDefault();
return false;
}
});
You could add quotes around the class like so:
class="form-control amount"
to specify that the class attribute has 2 classes:
$('body').on('keydown', 'input[class="form-control amount"]', function (e) {
console.log("key down");
if (e.which === 110 | e.which === 190) {
e.preventDefault();
return false;
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" class="form-control amount" placeholder="logs"/>
<input type="text" class="foo" placeholder="no logs"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With