Reputation: 166
$('.reporte, .maquinaria').on('change', function () {
var clase = $(this).hasClass('reporte') ? "reporte" : "maquinaria";
var item = {};
$(clase).each(function () {
item[$(this).attr('id')] = $(this).val();
});
json[clase].splice(0, 1);
json[clase].push({
item
});
console.log(json[clase])
});
if I make something like this:
$('.clase').each(function () {
item[$(this).attr('id')] = $(this).val();
});
it works. But I want to pass the class with the var clase that I already have.
Upvotes: 0
Views: 36