Reputation: 69
i have this code
<div class="form-group col-md-3">
<label for="exampleInputEmail1" class="col-md-12 texto_value">valor</label>
<div class="form-group col-md-6">
<input type="text" class="form-control" value="valor" disabled>
</div>
<div class="form-group col-md-6">
<input type="hidden" name="name_jacket[]" value="valor">
<input type="number" class="form-control" name="jacket_value[]"
id="valor" step="any" placeholder="valor">
</div>
</div>
This div is ijected by js with the function:
('#select_type').on('change', function(e){
but i need to create a keyup event on input name="jacket_value[]" but the keyup event doesn't work.
How can i make it works.
Upvotes: 0
Views: 1295
Reputation: 5123
Change your Javascript code like this.
$(document).on('change', "input[type='number'][name='jacket_value[]']", function(data) {
var btn = this;
console.log(this.value);
});
In this case you don't need to wait for the DOM to be ready $(document.ready() is not required.
You can simply use above code and it will work.
Upvotes: 2
Reputation: 705
Would you please try following way, It seems working fine.
$("input[type='number'][name='jacket_value[]']").on('keyup', function(e){
console.log(this.value);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group col-md-3">
<label for="exampleInputEmail1" class="col-md-12 texto_value">valor</label>
<div class="form-group col-md-6">
<input type="text" class="form-control" value="valor" disabled>
</div>
<br>
<div class="form-group col-md-6">
<input type="hidden" name="name_jacket[]" value="valor">
<input type="number" class="form-control" name="jacket_value[]"
id="valor" step="any" placeholder="valor">
</div>
</div>
Upvotes: 0