:-( Same result... if I inspect the name property using
jquery("newdiv....etc") is updated howere the html is not updated....



On 6 jun, 15:19, Sam Collett <[EMAIL PROTECTED]> wrote:
> On Jun 6, 8:50 am,oscaresp<[EMAIL PROTECTED]> wrote:
>
> > Thnaks... I have tryed:
>
> > jQuery("#"+inputID,addedItem).attr("id",newInputID);
> > content1= jQuery("#"+newInputID,addedItem)[0].outerHTML
> > content1=content1.replace(inputID,newInputID)
> > jQuery("#"+newInputID,addedItem)[0].outerHTML = content1
>
> > But any result....
>
> > My use case:
> > I have a div with inputs , I need to clone it , change all the id/
> > names and then insertAfert another div.
> > Seems that there are not way to change the name.
>
> > Another suggestion?
>
> I tried this and it seems to work fine for me (although not done any
> real in-depth testing(with different types of input etc) ):
>
> In $(document).ready
>
> var toclone = $("div.toclone");
> var cloned = toclone.clone().each(
>   function()
>   {
>     // update input names
>     $(":input", this).each(
>       function()
>       {
>         this.name = this.name + "1";
>         this.id = this.id + "1";
>       }
>     )
>   }
> ).insertAfter("div.afterme");
>
> HTML:
>
> <div class="toclone">
>   Foo: <input name="foo" id="foo" />
>   Bar: <input name="bar" id="bar" />
> </div>
> <div class="afterme">Clone after this</div>

Reply via email to