How to get the id or class of any element that is clicked using Jquery?I don't know the ID of the element i want asynchronouly clicked element ID.
            Asked
            
        
        
            Active
            
        
            Viewed 84 times
        
    2 Answers
0
            $(document).on('click',function() {
 var classes = $(this).attr('class');
 var id = $(this).attr('id');
});
This is for any click done on the page, for an specific element:
 $("#elem_id").on('click',function(){
     var classes = $(this).attr('class');
     var id = $(this).attr('id');});
 
    
    
        jonystorm
        
- 548
- 4
- 17
- 
                    Thanks,I don't know the id of element which is clicked want asnchronouly clicked element id. – Vishal Patil Mar 11 '16 at 07:45
- 
                    The first piece of code registers all clicks made, so on each click vars "classes" and "id" will be assigned with the classes and id of the element clicked – jonystorm Mar 11 '16 at 07:47
- 
                    thnx understood properly. – Vishal Patil Mar 11 '16 at 08:51
0
            
            
        In Html
You can do various logic on its click event as
 $('#idget').click(function(){
     ....//logic
    });
Or
  $('.customclass').click(function(){
      ....//logic
    });
 
    
    
        DAre G
        
- 177
- 10
