I am using the following code to run the javascript addeventlistener. but the event is only triggerable on ID of the input field which is all different
I am trying the following way but it does nothing, no error
$('.cds').click(function() {
var val_1 = document.getElementsByClassName('cds');
var val_Type = $(this).attr('data-id');
alert(val_Type);
console.log(val_1);
if (val_1.addEventListener) { // For all major browsers, except IE 8 and earlier
val_1.addEventListener("change", function(){
alert(val_Type);
});
} else if (val_1.attachEvent) { // For IE 8 and earlier versions
val_1.attachEvent("onchange", function(){
alert(val_Type);
});
}
});
ids are different for each input field having the same class, so i am bit lost here how can i do it in jquery