thanks for reply. I was also able to solve the problem with livejquery...
On 16 feb., 22:06, Karl Swedberg <[EMAIL PROTECTED]> wrote: > The problem here is that you are bind the "click" handler to > "#addsuggest2" when the document is first loaded, but that element > doesn't get created until you click on "#addsuggest" > > Unlike with CSS, which allows you to set styles for non-existent > elements that will be automatically applied if the elements are > created at a later time, JavaScript events don't work that way. There > is a plugin, called LiveQuery, which you might want to investigate, > because it "listens" for elements added to the document and applies > event handlers to them as appropriate. > > However, in your case, you could solve your problem with a simple > rearrangement of your code: > > $('a#addsuggest').click(function() { > > $('<a href="#" id="addsuggest2">add</ > a>').appendTo('#message').click(function() { > alert('working'); > });}); > > <a href="addsuggest">Add</a> > <div id="#message"></div> > > Note here that I used appendTo, which adds to whatever is already in > "#message". If you wish to replace the contents, you could precede > that line with this: > > $('#message').empty(); > > Hope that helps, > > --Karl > _________________ > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > On Feb 16, 2008, at 7:40 AM, FrEaKmAn wrote: > > > > > $('a#addsuggest2').click(function() { > > alert('working'); > > }); > > $('a#addsuggest').click(function() { > > //alert('working'); > > $('#message').html('<a href="#" id="addsuggest2">add</a>'); > > }); > > <a href="addsuggest">Add</a> > > <div id="#message"></div> > > > what is wrong? When I click on second add link (addsuggest2) nothing > > happens