You shouldn't need to use a named function, or an inline onclick. If you can move that id attribute into the <a> tag itself, you could do:
<span><a href="#" id="doedit_$comment[commentid]"> ... </a></span> and then your jQuery would be: $(document).ready(function() { $('a[id^=doedit_]').click(function() { alert(this.id); <-- shows that you have a handle on the specific element that triggered the click return false; }); }) On Mon, Sep 28, 2009 at 4:34 AM, lionel28 <lmarte...@haitiwebs.net> wrote: > > > Hi, > > I am trying to get the correct div from a form > > I did (I intentionally left the brackets open so it displays here) > span id="doedit_$comment[commentid]"> a onclick= "return > getCommentID($comment[commentid]) > > and for the jQuery > > $(document).ready(function() { > > function getCommentID(cid) > { > > $("#doedit_" + cid).click(function() { > > $("div#newcomment").slideUp("slow"); > $("div#editcomment_" + cid).slideDown("slow"); > > } > }); > > > But nothing is happening. > > Please what is the proper syntax? > > Thank you > -- > View this message in context: > http://www.nabble.com/How-to-handle-dynamic-clicks--tp25644199s27240p25644199.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.