What if you change

    $("a").click(function ()

To
    $("#a").click(function ()

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Patrick
Sent: Thursday, August 13, 2009 2:16 PM
To: jQuery (English)
Subject: [jQuery] Code inside click() event not firing.


New to jQuery, I did many searches before posting.

This is happening in both IE6 and Firefox 3.0.13.  I've gotten the
following script to work under strange circumstances (explained below
first snippet).

jQuery(document).ready(function(){
    showHint("");  // ajax that fires onload, with no problem (but did
try taking it out with same results)
    $("a").click(function () {
        alert("hi onclick"); // stuck this in there but doesn't fire
either.
        var avid;
        avid = "#div" + $(this).attr("id");
        alert(avid); // this won't work either.
        $(avid).fadeIn("slow");
        $(avid).css({display: block}); // added this extra when fadeIn
didn't work.
    });

});

When I'm able to successfully get both the alert and the rest of the
script to work is when I add another alert in the ready() section.
Then, the code works for the rest of the browser session (even after
the 'ready ()' alert is removed).

jQuery(document).ready(function(){
    showHint("");  // ajax/json
    alert("hi on load"); // after inserting this, the below all works
******************
    $("a").click(function () {
        alert("hi onclick"); // stuck this in there but doesn't fire.
        var avid;
        avid = $(this).attr("id");
        avid = "#div" + avid;
        alert(avid);
        $(avid).fadeIn("slow");
        $(avid).css({display: block}); // added this extra when fadeIn
didn't work.
    });

});

Any clue why this would be happening?

Thanks,
Pat.

Reply via email to