I've created two of selection and check up with items was selected by using on jQuery method.
I have two of selector id (#idchief, #teller) and I will use $(document).on method to check up if an item was selected but I don't want to use document.on () twice. I want to check if on selection was select and process of this selection.
$(document).on('change','#idchief', function (event) {
console.log($("#idchief"));
var id = parseInt($("#idchief").val());
for(var keys in cheifs) {
var vals = cheifs[keys];
if(parseInt(vals.id) === id){
console.log(vals.id);
}
}
});
$(document).on('change','#teller', function (event) {
var vals = null;
var sel = $("#teller").val();
for(var key in tellers) {
vals = tellers[key];
console.log(sel)
if(vals.id == sel){
$('input[name=amount]').val(vals.balance)
}
}
});
I have tried this
$(document).on('change','#teller,#idchief', function (event) {
if($teller){
//code here
}if(#idchief)(
///code here
)
});
Use is()
$(document).on('change','#teller, #idchief', function (event) {
if ($(this).is('#teller')) {
// OR
// $(this).attr('id') === 'teller'
// OR
// this.id === 'teller'
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