get id from element when click on then insert to another jquery seletor to perform another function?

get id from element when click on then insert to another jquery seletor to perform another function?

Here is my code

$('.info_show').click(function(g){
      var a = $(g.target).attr('id');
      $('.icon').click(function(e){
            $(a).removeClass('red blue black').addClass($(e.target).attr('value'));
       });
});

Is there something wrong?

Thanks & sorry about my English.