Jump to content


Photo

Don't want to affect all class elements

jquery animate

Best Answer kicken, 06 May 2013 - 01:31 PM

$('.remove_cart_item', this)
That sets the context so it will only search nodes under the this node, which would be the div that is currently being moused over. Go to the full post


  • Please log in to reply
4 replies to this topic

#1 1internet

1internet
  • Members
  • PipPipPip
  • Advanced Member
  • 137 posts

Posted 05 May 2013 - 08:40 PM

$('.cart_item').hover(function(){
    $('.remove_cart_item').fadeToggle();
});

So the issue is that when I hover over the div class cart_item, all the divs with class cart_item show the hidden div class remove_cart_item.

How do I get it to just show for the div its hovering over?



#2 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 05 May 2013 - 09:24 PM

Use $(this)
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#3 1internet

1internet
  • Members
  • PipPipPip
  • Advanced Member
  • 137 posts

Posted 05 May 2013 - 10:17 PM

$(this).$('.remove_cart_item').fadeToggle();

 

??

The hidden element is a child of the hover element.


Edited by 1internet, 05 May 2013 - 10:18 PM.


#4 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 05 May 2013 - 10:28 PM

So add the children selector...
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#5 kicken

kicken
  • Gurus
  • Wiser? Not exactly.
  • 3,317 posts
  • LocationBonita, FL

Posted 06 May 2013 - 01:31 PM   Best Answer

$('.remove_cart_item', this)
That sets the context so it will only search nodes under the this node, which would be the div that is currently being moused over.
Did I help you out? Feeling generous? I accept tips via Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7
Kicken's World⦄ ⦃Recycle old CD's




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users