Skip to content Skip to sidebar Skip to footer

Jquery Insert Row With Row Number In Names

I have a markup like this
NameTitleSelect Test

Solution 1:

Try this:

ParentClone.find('input').each(function() {
                $(this).attr('name', $(this).attr('name') + Rows);
            });

No need to have $ around it.

Solution 2:

there is some silly mistake as its not jquery selector so no need to write $

ParentClone.find('input').each(function() {
                $(this).attr('name', $(this).attr('name') + Rows);
            });

Solution 3:

ParentClone is already jquery object which you have defined above in code:

varParentClone = $('table#document-data tr.new-document-meta').last();

it is not selector so you don't need to do $(ParentClone) as it is already jquery object just use it ParentClone.find(....)

ParentClone.find('input').each(function() {

Solution 4:

For the incremental name value, you need to cast the number of rows as string when you define it, then it will concatenate as desired when defining the name attribute. Replace your Rows defintion with this:

varRows = String($('table#document-data tr').length);

Post a Comment for "Jquery Insert Row With Row Number In Names"