KBD

Keith Devens .com

Saturday, July 5, 2008 Flag waving
Show, don't tell. – unknown
← The annoying way to .clone() a list in C#A history of 'swipe' →

Daily link icon Friday, July 13, 2007

Javascript toggle functions

Some more handy Javascript (depends on Prototype):

function toggleByClass(id, className, callback){
    // shows the element with id 'id'
    // and hides all other elements with class 'className'
    $A($$('.'+className)).each(function(element){
        $(element).style.display = "none";
    })
    if(id) // call it with a false id to hide all
        $(id).style.display = "block";
    if(callback)
        callback(id, className);
}

function toggleById(id1, id2){
    var a = $(id1).style;
    var b = $(id2).style;
    if(a.display == 'none' || a.display == ''){
        a.display = 'block';
        b.display = 'none';
    }else{
        a.display = 'none';
        b.display = 'block';
    }
}
← The annoying way to .clone() a list in C#A history of 'swipe' →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

Girls, please don't get breast implants

> And no, you will not be receiving​a picture.

:-(...

Keith: Jul 2, 6:05am

Javascript clone function

This is a clever way to clone an​object if you are using YAHOO UI.​Same tec...

Antonio: Jul 1, 12:47pm

I hate Norton Antivirus

Oh just one other thing norton is​great at keeping people out of your​compu...

kevin.sands: Jul 1, 12:50am

Terminator 3 was awful

I think the biggest reason why T3​totally blew was because Edward​Furlong g...

76.167.172.64: Jun 29, 3:06am

Generated in about 0.102s.

(Used 8 db queries)

mobile phone