Hey people
I'm seeking an js menu like the link below.
jQuery would be a plus!
Hey people
I'm seeking an js menu like the link below.
jQuery would be a plus!
Ohh yes sry :-)
When you mouseover the top menu "Shows", it shows many other menu options.
are there any tutorials/ open source js/jquery scripts for a menu like that one ?
Instead of linking to someone else's menu, I thought I'd give some pointers as to how you might go about making your own from scratch.
You probably already understand how web-pages are divided into blocks (divs), and you can style those blocks using CSS. Knowing this you can ask yourself -- what's so special about the "Shows" menu? Ignoring the JavaScript needed to show it, hide it, and change its colours; could you write the static HTML and CSS to display it on an empty page?
To make things easier to visualise, grab yourself a sheet of paper and a pencil and get scribbling! As you start writing more and more complex code, a notepad will become one of your most valued tools. I won't even start a GUI project these days until I've drawn out a basic storyboard for it.
Now you can start to think about how to programmatically create what you have drawn and coded statically. By far the best place to start is by defining the data-structures that represent the menu-items themselves, for example:
In the main "Shows" menu I can see only 4 arrays: One that represents the standard-menu on the far left:
SideMenu = [ 'TV Schedule', 'MTV Shows Gossip', etc... ]
And three more that represent the "Shows", "Specials", and "Classic Shows" menus respectively:
Shows = [ '16 and Pregnant', 'America\'s Best Dance Crew', etc... ]
Specials = [ '2009 Video Music Awards', '2009 Movie Awards', etc... ]
Classics = [ 'Aeon Flux', 'Beavis and Butt Head', etc... ]
From here you can think about how you would iterate over each array and the special-cases you need to take care of. Particularly, the "Shows" submenu is split over two columns. Before you think about the HTML involved, think about how your for-loop would know when it reaches the end of a "page" in your array, and how it would start a new one.
Finally, once you've dealt with your data-structures and drawing-routines, you can think about event-handling. ie; what to do when the mouse moves about the page. As you probably know, CSS can be used to change colours when the mouse moves over items, and you can use jQuery to apply handlers and show/hide your divs.
Sorry this ended up being a bit of an essay/rant -- I did not intend it as such! The Internet is a great resource for cut/pasting snippets of code that "just work" (I'm looking at you, gurus of SO ;-) but it can make us lazy and dependant. While that's fine for quick-fixes (and such things are very prevalent in the world of web design) it should not be your basis for development.
Remember The Law of Leaky Abstractions! Strive for understanding of what you are trying to achieve at the most fundamental level that your tools and abilities will allow -- this is the secret to getting the most out of abstractions (like jQuery) designed to make your day-to-day coding life easier.