javascript - How can I take the content of dynamic fields when click on submit -


i have jquery function add dynamically title , text fields.

code: jdfiddle

when click on "add new" button info (title , text) saved array of object "info":

function info(title, text){     this.title = title;     this.text = text; }  var listinfo = []; 

after that, "add new" button shows new field complete. on.

i don't know how can manage id of every field. take values simple, use $("#id").val(). id must different!

some ideas? , if decide modify text of field inserted? how can overwrite specific element of array? .keypress() function? ok, remains id problem..

add randomy number id should work fine, find example here random id :

var id = math.floor(math.random() * (1000000 - x)); 

your exemple worked random id


Comments