Thanks for all the advices! It was a very newbie error :P Can i ask another little question?
Starts with this code (a new version of what i posted early) ------------------------ $(".imagencap").bind("click", function(){ if($(this).children().is("textarea")){ return; } //return if textarea is already created var myP = $(this).find("p"); var myCaption = myP.text(); var myId = myP.attr("id"); //alert(myId+": "+myCaption); var textarea = "<textarea id="+myId+" cols='9' rows='9'>"+myCaption +"</textarea>"; var buttons = "<span class='savencancel'>[<a href='#save'>SAVE</a>] [<a href='#cancel'>CANCEL</a>]</span>"; myP.hide(); myP.before("<br /><br />"+textarea+""+buttons); $(this).find("span").find("a").bind("click", function(e){ e.preventDefault(); if($(this).attr("href") == "#save"){ //alert("salvo!"); } if($(this).attr("href") == "#cancel"){ //alert("cancello!"); $(this).parent().hide("slow"); $ (this).parents(".imagencap").children("textarea").hide("slow"); //$(this).parents(".imagencap").children("textarea").remove(); $(this).parents(".imagencap").find("p").show(); } }); }); ------------------------ Well, this code put a "SAVE" and a "CANCEL" links at the bottom of the textarea (for each images). When i click "CANCEL" i would to do that textarea and button hides and the <p> came back. In code i've posted, when i click on these links the click event propagate to the imagencaption class, so: - if i hide the textarea, i can't do any change anymore (the check at the first line returns true). - if i remove the textarea, a new textarea appears (because the check at the first line fails). Any idea? Thanks! On 27 Apr, 19:13, steve_f <[EMAIL PROTECTED]> wrote: > 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 :)