tags:

views:

21

answers:

1

Hi,

I'm trying to manipulate two elements within a jquery function and i'm not seeing the light. I'm using the following code which works well on showing the required div, but i would like to add highlighting to a paragraph item in another part of the page as well?

$('.lang-click').click(function(event){
  $('.lang').hide();
  $("li").removeClass("lang-on");
  event.preventDefault();
  $(this).parent().addClass("lang-on");
  $($(this).attr('href')).fadeIn(500);     
 });

I have tried this - which does not work:

$('.lang-click').click(function(event){
  $('.lang').hide();
  $("li").removeClass("lang-on");
  event.preventDefault();
  $(this).parent().addClass("lang-on");
  $($(this).attr('href')).fadeIn(500);
  var href = $(this).attr('href');
  $($(this).attr('href', href + '-cont')).addClass("cont-on");
 });
A: 
$($(this).attr('href', href + '-cont')).addClass("cont-on");

Maybe this line is the problem?

$(this).attr('href', "something") 

returns the link element itself, not "something".

Is this, what you're trying to do?

$($(this).attr('href')+ '-cont').addClass("cont-on");
flitzwald
Great thanks - that now works. no need for the var either.
squeaker