Okay, here's the problem:
i have these three DIVs:
<div id="gestaltung_cd"></div>
<div id="gestaltung_illu"></div>
<div id="gestaltung_klassisch"></div>
…and these three DIVs – which are invisible (display:none;)– on a completely different position on the page:
<div id="mainhexa1"></div>
<div id="mainhexa2"></div>
<div id="mainhexa3"></div>
what i want to do is: if i hover "gestaltung_cd" i want to make "mainhexa1" visible and if i hover "gestaltung_illu" i want to make "mainhexa2" visbile and so on…
as you can see, the three invisible DIVs are no child-elements of the first three ones... so ":hover" is not possible in this case. Is there an easy way to do this in JQuery?
thanks, Jochen
If you wrap each block of divs in a container you can match them up by index, which will make the code work regardless of how many divs there are. Something like this:
Example fiddle
using jQuerys hover function, like this:
(if you don't want to hide the div on blur, then change toggle() to show())
Here's an example of how to do the first one and you'd just do the same for the other two with the relevant IDs.
Just for the record ...
You can do the effect you want only with CSS and HTML ( without javascript ), but you have to place your elements to follow each other and use
+
selector in CSS. Something like :HTML
CSS
you can check out the demo http://tinkerbin.com/KP17XUgq
Using jQuery's hover function :
Note that it might be easier to have some relation between the opener and opening elements, like a class or another attribute (as in nnnnnn's answer).