Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hovering Over a Child Part to Change Parent?

Status
Not open for further replies.

jbtman

Programmer
Jul 13, 2007
30
Hi There!

I was wondering if it were possible to change the attributes of a parent element when hovering over a child element inside the parent.

For instance if I had the following:

<div id="parent">
<a class="link" href="#"></a>
<div>

Could I hover over the link and then resize the div with CSS?

Thanks!!
 
No. It would indeed be useful to be able to do that, but unfortunately, it is not.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
You'd have to use JavaScript, e.g.:

Code:
<div id="parent">
   <a class="link" href="#" [!]onmouseover="this.parentNode.className = 'hovered';" onmouseout="this.parentNode.className = '';"[/!]></a>
<div>

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I might have dreamt it (I have odd dreams) but I think I read something about a CSS3? selector using the <

i.e.
Code:
parent<child {
  color:#f00;
}

Now I write it I'm more convinced it was a dream though.

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
That's what I thought too BillyRay thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top