Don't understand when this could occur to make any sense for images
being inserted like this without an example, but at any rate...

You'll have to think about when and how this is triggered in order for
these if statements to be executed because as said, i don't understand

switch ($('#main').attr('class')) {
        case 'aa':
                
insertImg('/path/to/your/images/some_image_for_the_aa_class.jpg');
                break;
        case 'bb':
                
insertImg('/path/to/your/images/some_image_for_the_bb_class.jpg');
                break;
}

function insertImg(path) {
        $('#main').prepend('<img src="'+path+'"/>');
        return 0;
}

On Jul 11, 9:27 am, brendan <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I'm using Seamus Leahy's AddAClassNameAtRandomToAnElement.js (http://
> moronicbajebus.com/2006/07/30/add-a-class-randomly-from-a-set/) to add
> a random class to a div, and then trying to insert an image based on
> the random class name.
>
> So if I have
>
> <div id="main" class="aa">
>
> I'd like to say "if #main.aa, then insert image1.jpg; if #main.bb,
> then insert image2.jpg; etc.
>
> Just can't seem to get the syntax right. Or is there a better way to
> go about this? Any help is very much appreciated

Reply via email to