ThemeForest

Need help with javascript and div

4265 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Interviewed on the Envato Notes blog
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
Reaper-Media says

Hi guys. I posted this earlier on theme forest but didn’t get much of a response, maybe i was missing out detail, but anyway, here is my situation. I’m trying to make a menu (a news archive menu) where you can hover over the year, and then below that year, all the months of the year will appear.

Let me explain:

1. The user is not hovering over the year (2007 in this example):

2. The user hovers over the year 2007 and the div containing the months starts to be revealed. Pushing the content below it down.

3. As the transition continues, even more of the div is revealed, pushing the content below it even further down.

4. Eventually the entire div is revealed, as if it was there from the start.

My Code structure is like this:

<ul>
<li>2007</li>
<div id="2007months">
      </div><li>December</li>
      <li>November</li>
      <li>October</li>
      <li>September</li>
      etc...

<li>2006</li>
<div id="2006months"> etc ... 
</div>

<li>2005</li>
<div id="2005months"> etc ... 
</div>

etc...

</ul>

Basically, i would like to apply the transition to the DIVs, and allow for the transition to be reversed for when the user rolls out.

Does anyone know any scripts like this, or know how they would go about making one, javascript would be the most ideal solution as i am familiar with it..

I am currently using display:block and display:none, but it does look quite tacky when you roll over the menu and suddenly the months appear. Doesn’t look to pleasing to the eye…

Thanks in advance
Sam

Posted 2 years ago VIA ActiveDen | Permalink
Reaper-Media is an Envato staff member
382 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • United States
  • Referred between 1 and 9 users
blabus says

I believe something like this is what you’re looking for: http://www.i-marco.nl/weblog/jquery-accordion-menu/

If not, just search for “javascript accordion menu”, that’s what they’re called. :)

Posted 2 years ago VIA ThemeForest | Permalink
2544 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Netherlands
  • Referred between 10 and 49 users
Joost says

Or if you don’t understand Jquery at all, you could just use this easy to apply Motion Tween Engine I’ve relied on for a while now. Works great, cross-browser too :)

http://jstween.blogspot.com/#TweenMethodsEx

Posted 2 years ago VIA ActiveDen | Permalink
Joost is an Envato staff member
4265 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Interviewed on the Envato Notes blog
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
Reaper-Media says

Okay, decided to go with the jQuery method. So all you jQuery pros out there need to answer another question.

I have an event that detects when any of the div’s within the object #menu are rolled over:

$('#menu div').hover(
    function() {
        //stuff goes here
      }
    );

But i’m not sure how to select the ul object within that div, so where i have ”//stuff goes here” i need to move down the ul. ie:

$('#menu div').hover(
    function() {
        $(correct item).slideDown('normal');
      }
    );

and i have no idea how to get the “correct item”, or the child to the DIV , i already have the $(this) working.

i have tried the following:

$(this).('ul').slideDown('normal');
$(this 'ul').slideDown('normal');
$(this . 'ul').slideDown('normal');

Obviously none of them work, all i want to do is select the ul within this...

help please… :)

Posted 2 years ago VIA ActiveDen | Permalink
Reaper-Media is an Envato staff member
4265 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Interviewed on the Envato Notes blog
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
Reaper-Media says

Never mind… got it:

 $(this).find('ul')
Posted 2 years ago VIA ActiveDen | Permalink
Reaper-Media is an Envato staff member
4265 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Interviewed on the Envato Notes blog
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
Reaper-Media says

Haha, just had so much trouble with the event .mouseout , it triggers even when you dont want it to, found out i needed to use .mouseleave instead :D

Posted 2 years ago VIA ActiveDen | Permalink
Reaper-Media is an Envato staff member
6322 posts
  • Has been a member for 3-4 years
  • Won a Competition
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 50 and 99 items
  • United Kingdom
  • Referred between 10 and 49 users
MSFX says

the real answer?

use Flash :)

Posted 2 years ago VIA ActiveDen | Permalink
MSFX is an Envato staff member
4265 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Interviewed on the Envato Notes blog
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
Reaper-Media says
the real answer? use Flash :)

Possibly…

Anyway i got it all working now and i’m quite happy :) Didn’t want to use flash for the fundamental stuff like menus, might do it for showcase etc. though.

Oh yeah… just for the record… this is a client’s site :D

Posted 2 years ago VIA ActiveDen | Permalink
Reaper-Media is an Envato staff member
382 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • United States
  • Referred between 1 and 9 users
blabus says
the real answer? use Flash :)

Flash is never the answer.

Posted 2 years ago VIA ThemeForest | Permalink
961 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Grew a moustache for the Envato Movember competition
  • Exclusive Author
  • Beta Tester
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United States
webdesigndeluxe says
the real answer? use Flash :)
Flash is never the answer.

Agreed :)

Posted 2 years ago VIA 3DOcean | Permalink
by
by
by
by
by