![]() |
Is there a simpler way of doing this ?
Hey, so i have 4 Divs around a Circle, and when you hover, that content is displayed inside of the circle.
This is what i have working. Is there a simpler way of doing this ? Or would this be proper ? Code:
<script type="text/javascript"> |
Well, if I understand your code correctly, you have 4 elements (ss1, ss2, ss3, ss4) and one content holder (sc) in which you want to display custom content when hovering the ss1 to ss4 elements.
What I don't undersand from your code is the relation between your elements. Hovering ss1 displays sc2 / ss2 -> sc3 / ss3 -> sc1 / ss4 -> sc4 :confused: A quite easy approach would be to use a common class for your hover elements and loop through them, then replacing the main container's content with another DIV's content, based on your hover elements' ids. PHP Code:
PHP Code:
Do you get the point? Of course, there are other ways to do that, with less HTML, having each element's content in a javascript array for example. This is quick and dirty but illustrates how you can loop through a range of HTML elements and interact with others, and simplify your javascript code by the use of .each() and $(this). |
You don't even need to do the looping-event-attaching thing, do you? Why not just:
PHP Code:
|
True. You can do that too, it's even simpler.
Your code has a typo though, so here is a clean version: PHP Code:
|
| All times are GMT +1. The time now is 03:53 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.