Hola pruebe lo soguiente <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <input type="text" id="uno" class="demostracion"> <input type="text" id="dos" class="demostracion"> <input type="text" id="tre" class="prueba"> <input type="text" id="cua" class="prueba"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- ATENCION AQUI --> <script> $(document).on('keyup', '.demostracion, .prueba', function() { console.log($(this).attr('id')); }); </script> <!-- ------------- --> </body> </html> <!-- end snippet -->