Jquery get only the class target of an event

I would like to get the class that firing the alert

The problem is that all the class of the <i> will be alert on the

trigger('click'), I just want to get the class used

Here a example with the class main

Html

<i class="main mainBack another another2 another3"></i>

Jquery

$(document).on('click','.main, .mainBack', function(e) {
   alert(e.target.className);
});

$('.main').trigger('click');

Jsfiddle

http://jsfiddle.net/474x5ew5/1/


Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.