[jQuery] Div Changer Script Using Show and Hide
I was just wondering if someone could give this a quick look and see if there is anything wrong with it. It seems to be working on the web site but perhaps there is something I could do to make it more efficient. $(document).ready(function(){ //THIS HIDES ALL LISTED DIVS ON LOADING OF PAGE $('div.blackbook').hide(); $('div.canvas').hide(); $('div.pencil').hide(); $('div.murals').hide(); $('div.shows').hide(); $('div.tattoos').hide(); $('div.miscellaneous').hide(); $('a#blackbook').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.blackbook').show('fast'); return false; }); $('a#canvas').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.canvas').show('fast'); return false; }); $('a#pencil').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.pencil').show('fast'); return false; }); $('a#murals').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.murals').show('fast'); return false; }); $('a#shows').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.shows').show('fast'); return false; }); $('a#tattoos').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.tattoos').show('fast'); return false; }); $('a#miscellaneous').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.miscellaneous').show('fast'); return false; }); }); //HIDES ANY VISIBLE DIVS hide_divs = function() { //HIDE ANY VISIBLE DIVS BEFORE CONTINUING if ($('div.main').is(':visible')) { $('div.main').hide('fast'); } if ($('div.blackbook').is(':visible')) { $('div.blackbook').hide('fast'); } if ($('div.canvas').is(':visible')) { $('div.canvas').hide('fast'); } if ($('div.pencil').is(':visible')) { $('div.pencil').hide('fast'); } if ($('div.murals').is(':visible')) { $('div.murals').hide('fast'); } if ($('div.shows').is(':visible')) { $('div.shows').hide('fast'); } if ($('div.tattoos').is(':visible')) { $('div.tattoos').hide('fast'); } if ($('div.miscellaneous').is(':visible')) { $('div.miscellaneous').hide('fast'); } } Any comments would be appreciated.
[jQuery] Re: Why does it take so long for a new topic to be posted?
On Feb 22, 8:41 am, gh0st [EMAIL PROTECTED] wrote: Why does it take so long for a new topic to be posted? It really is frustrating esp, if you want answers to questions. It has nothing to do with 'Google'. If you look at the link on the right that says 'About This Group' it says something like: Messages By New Members Are Moderated. So basically your topic is sitting there waiting to be authorized by an administrator.
[jQuery] Div Changer Using Hide And Show
I created this script to hide and show divs on a web page I am working on. It is working properly as far as the effects on the page go. I was just wondering if there is any way I can clean it up or make it simpler. Thanks. $(document).ready(function(){ //THIS HIDES ALL LISTED DIVS ON LOADING OF PAGE $('div.blackbook').hide(); $('div.canvas').hide(); $('div.pencil').hide(); $('div.murals').hide(); $('div.shows').hide(); $('div.tattoos').hide(); $('div.miscellaneous').hide(); $('a#blackbook').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.blackbook').show('fast'); return false; }); $('a#canvas').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.canvas').show('fast'); return false; }); $('a#pencil').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.pencil').show('fast'); return false; }); $('a#murals').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.murals').show('fast'); return false; }); $('a#shows').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.shows').show('fast'); return false; }); $('a#tattoos').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.tattoos').show('fast'); return false; }); $('a#miscellaneous').click(function() { //HIDE DIVS hide_divs(); //SHOW LISTED DIV $('.miscellaneous').show('fast'); return false; }); }); //HIDES ANY VISIBLE DIVS hide_divs = function() { //HIDE ANY VISIBLE DIVS BEFORE CONTINUING if ($('div.main').is(':visible')) { $('div.main').hide('fast'); } if ($('div.blackbook').is(':visible')) { $('div.blackbook').hide('fast'); } if ($('div.canvas').is(':visible')) { $('div.canvas').hide('fast'); } if ($('div.pencil').is(':visible')) { $('div.pencil').hide('fast'); } if ($('div.murals').is(':visible')) { $('div.murals').hide('fast'); } if ($('div.shows').is(':visible')) { $('div.shows').hide('fast'); } if ($('div.tattoos').is(':visible')) { $('div.tattoos').hide('fast'); } if ($('div.miscellaneous').is(':visible')) { $('div.miscellaneous').hide('fast'); } } Do I need to use a div_switch = false somewhere in my script to call it back to null? I'm not sure if I'm posing that question correctly, I'm just concerned about an open loop etc.