views:

35

answers:

0

I have a few checkboxes on my form. I would like to run a bit of javascript when someone clicks them. I've tried the following code after much head scratching and have no idea why its not working.

$().ready(function () {
    $('#uploadDirs').find(':checkbox').each(function () {
        $(this).attr('onClick', "alert('hello');");
        $(this).click(function () { alert('bye'); });
    });
});

I only get an alert with hello, none for bye. If I remove the attr() call, I still get no alert for bye. This is in firefox, safari and chrome (I haven't tried in IE).

Any ideas as to why .click() isn't doing its thing?