SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with cloned field

    hi

    i have this http://jsfiddle.net/xP9Bx/ that wotks well

    now i am trying to change `<input id="input1" />` to `<div id="input1"> </div>` http://jsfiddle.net/J7sMr/.

    The problem is the id, it is supposed change, like input1, input2, but in the second example the new divs always have the same id.

    In the first example the name of the id's are input1, input2, input3,...

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    solved


    Code:
            $('#btnAdd').click(function() {
                $('.btnDel:disabled').removeAttr('disabled');
                var c = $('.clonedInput:first').clone(true);
                    c.children('div').attr('id','input'+ (++inputs) ).val('');
                    c.children(':button').attr('name','btnDelete'+ (inputs) );
                $('.clonedInput:last').after(c);
            });


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •