Do you have multiple divs with the same id of 'images'?. if so you need to start using class name selectors, then you can iterate all the divs with that clas name e.g $(".images").each
On Apr 27, 11:25 am, LostCore <[EMAIL PROTECTED]> wrote: > Hi! > > Well, i'll quickly describe my problem. > > In a page, i've multiple occurrence of: > > [code] > <div id="images"> > <div id="imagencap" style="float:left;"> > <img src="fileName.jpg" /> > <p id="caption_id"> > caption_text > </p> > </div> > </div> > [/code] > > I would do, that when i click on a "caption_text", the relative > paragraph tag hide, and a textarea appears, with the text of the <p>. > > Then, i've scripted this: > > [code] > $("#images").find("#imagencap") > .click(function(e){ > > if($(this).children().is("textarea")){ return; } > > var myP = $(this).find("p"); > var myCaption = myP.text(); > var myId = myP.attr("id"); > > var textarea = "<textarea > id="+myId+">"+myCaption+"</textarea>"; > var buttons = "[<a href='#'>SAVE</a>] [<a > href='#'>CANCEL</a>]"; > myP.hide(); > myP.before("<br />"+textarea+"<br />"+buttons); > }); > [/code] > > ... That works!. But only for the first occurrence! > > Where is the problem? > > Thanks :)