How to get id from class selector from jquery

To get id of a selected class using jquery DOM use the function given below.

$(‘.test’).click(function() { 

    console.log(this.id); 
});
In the above code test is the class name.
While using this.id  we will be able to fetch id of that class

Tags: No tags

Leave A Comment

Your email address will not be published. Required fields are marked *