Getting the class of the element that fired an event using JQuery
问题 is there anyway to get the class when click event is fired. My code as below, it only work for id but not class. $(document).ready(function() { $("a").click(function(event) { alert(event.target.id + " and " + event.target.class); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <html> <body> <a href="#" id="kana1" class="konbo">click me 1</a> <a href="#" id="kana2" class="kinta">click me 2</a> </body> </html> jsfiddle code here 回答1: Try: $