Jump to content


Photo

Don't want to affect all class elements

jquery animate

Best Answer kicken, 06 May 2013 - 08:31 AM

$('.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

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 05 May 2013 - 03: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

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 05 May 2013 - 04: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

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 05 May 2013 - 05:17 PM

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

 

??

The hidden element is a child of the hover element.


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


#4 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 05 May 2013 - 05: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

    Wiser? Not exactly.

  • Gurus
  • 2,678 posts
  • LocationBonita, FL

Posted 06 May 2013 - 08:31 AM   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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com