Javascript examples for jQuery:Tag Traversing
Get selector on which 'click' event has been bound
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(function(){//from w w w .j a va 2 s .c o m $('#page-container, .some-class').on('click', function (event) { console.log($(this).text()); }); }); </script> </head> <body> <div class="some-class"> Hello </div> <div id="page-container"> how are you </div> </body> </html>