javascript - Clone element and increment index placed in name by 1 -


Let's say I have this input:

name = "fade_inisio [2] "

And I want to clone and generate it:

name =" fade_inisio [3] "

How do I do this?

I tried to do something like this, but its ugly and it will not work.

  var $ input = $ original.clone (); Var name = $ input.attr ('name'); Name.replace ('[' + (Indis-1) + ']', '[' + + + ''] '); $ Input.attr ('name', name);  

does not modify the string in the locale space, but returns a new string. Then your code should be:

  name = name.replace ('[' + (Indis-1) + ']', '[' + + + '' + '+)];  

In addition, you do not really need such index names, you can go with just name = "fecha_inicio []" and about the index Do not worry later you will get form data which has a serialize method.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -