Creo que esto te puede ser útil <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> $('#btn_1, #btn_2').on('click', function() { console.log($('#' + $(this).attr('id')).text()); }); <!-- language: lang-html --> <script src="https://code.jquery.com/jquery-3.0.0.js"></script> <button id="btn_1"><span>Span1</span> Button 1</button> <button id="btn_2"><span>Span2</span> Button 2</button> <!-- end snippet -->