Question: I have number of element which have same class name. But i want to give id for one the element which is clicked by the user.

```
 $('body').click(function(event) {
    $(document).on('click', '.l1', function(){
        $('.l1').removeAttr('id');
        $('.l1').attr('id','selected');
    });
    $(document).on('hover', '.l1', function(){
    alert($(this).attr('id'));
    });
 });

```

Fiddle :

<http://jsfiddle.net/JamesPJ/h722g/141/>

Answer: 
`$('.l1')` will always select all elements of that class, disregarding the fact that you are inside a click event for one specific element.

You want to use `$(this)`

[Demo](http://jsfiddle.net/9eq8U/)
Use `$(this)` so that it will point the element you've clicked

```
$(document).on('click', '.l1', function(){
        $('.l1').removeAttr('id');
        $(this).attr('id','selected');
    });

```