Is it possible to have an element controlling another element's property? For example, a:hover a link would trigger the visilbility of a div? If this is possible, how would the coding be like?
| SitePoint Sponsor |


Is it possible to have an element controlling another element's property? For example, a:hover a link would trigger the visilbility of a div? If this is possible, how would the coding be like?


hmm so I am guessing that this only works in the case of hover with span?


I see I see, thx a lot!


hmm, I seem to have ran into some problems with this. How come I couldn't use the span tag to control a part of the list. Here are the codes
HTML
CSS:Code:<ul> <a href=""><li>Click</li> <span> <li>fdsafsaf</li> <li>dsafdsaf</li> <li>fdsafsdfa</li> </span> </a> </ul>
Code:span{ visibility: hidden; } a:hover span{ visibility: visible; }
A span is an inline element and can't contain block elements (list items). Apart from that, everything inside a list (ie between the <ul> & </ul>) most go inside a list item tag pair (<li></li>).


so what do you suggest me to do if I want only part of the list with the hover effect, or is it not achievable?
You could add classes to the part you want the effect to work on. Consider the following code:
Code:<html> <head> <style> a.test:hover { color: orange; } </style> </head> <body> <a class="test" href="#">blaat</a> <a href="#">pipo</a> </body> </html>
Hippopotomonstrosesquippedaliophobia - Fear of long words


Yea, I know that's achievable, thx though, but what I am looking for is if it's possible to do it for only a part of a list, like in my post above #8.
I'm not sure what you were trying to achieve in that post, but I'm guessing you need to nest another list inside your list:
You can then control the nested list with something like this:Code:<ul> <li> <a href="#">Click</a> <ul> <li>fdsafsaf</li> <li>dsafdsaf</li> <li>fdsafsdfa</li> </ul> </li> </ul>
You'll need some javascript to get the hover to work in IE (it only supports the hover pseudoclass on anchors):Code:li ul li { display: none; } li:hover ul li, li.hover ul li { display: block; }
If this is not what you're looking for, please explain yourself again.Code:hover = function() { var li = document.getElementsByTagName('li'); for (i = 0; i < li.length; i++) { li[i].onmouseover = function() { this.className += ' hover'; } li[i].onmouseout = function() { this.className = this.className.replace(' hover', ''); } } } if (window.attachEvent) window.attachEvent("onload", hover);
Hippopotomonstrosesquippedaliophobia - Fear of long words


Sorry if it was confusing before, but yep this is what I am looking for, ok I'll test it out now, thx!
Bookmarks