1

everyone! I did this:

$('#kill').live('click',function(){
   $closeId = $(this).parent().attr('id');
   $('#suggested').find('#' + $closeId).removeClass().addClass('active');
});

and it doesn't work. I tried to test it:

var $test = $('#suggested').find('#' + $closeId).length;

and it's return '0', it's incorrect. It would be great if you know how to fix it.

Thanks!

1 Answers1

3

Do

$('#kill').live('click',function(){
   $(this).parent().removeClass().addClass('active');
});

Notes :

  • You don't have to get the id if you just want the element.
  • Don't use find if you have the id. As you can only have one element with a given id in a document, the most efficient is to use $('#' + $closeId).
  • with new jQuery versions, don't use live but on.
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
  • thanks for reply. Let me explain: i have 2 div's and one input for tags; #kill removing current tag from input and i whant make this tag visible/active in both div's again. And yes - current tag has same id in all cases. – user1726862 Oct 08 '12 at 20:00