you just need to refine your selector for p tags to fit the appropriate parent element

lots of ways to do this

if the p tags are in the .box div you are hovering change:
$("p").css('color','#fff')

to
$(this).find("p").css('color','#fff')

A more flexible way to do this would also be to addClass on hover, remove class on out, then define your style in css sheet. In my mind is much easier to make modifications this way
CSS
.newClass {//set css properties}
.newClass p{//set css properties}

 

Jacques Choquette - WhistlerGraphicDesign.com wrote:
I have the following code

$('.box').hover(
  function(){ $(this).css('background-color','#6bc6f2'); $("p").css
('color','#fff') },

function(){ $(this).css('background-color','#fbf9f9'); $("p").css
('color','#000') }

);

I have the .box class applied to a div basically I what to hover over
the div change the background color of the div and at the same time
change the text color of any text wrapped in p tags.

I am getting close but with this code every instance of the p tag gets
swapped out I need to know how to target only p tags in the div that I
am mouseing over

can somebody please help!

  

Reply via email to