javascript - Jquery concatenting very simple counter with a Variable -


following question, have working script create dynamic form fields : fiddle

i thought figure out rest, not understand why when try assign new name , id attributes textarea, gives me nan.

if :

i++;  var newname = jquery(prevdiv).attr('name');     prevdiv.find('textarea').attr('name',i ); 

it sets ok, if try :

prevdiv.find('textarea').attr('name',newname +i ); 

..which need - nan.

i know js qualities close zero, syntax wrong ?

you have no name attr in jquery(prevdiv) element. name attribute on textfield.

your code should :

    var newname = jquery(prevdiv).find("textarea").attr('name');     prevdiv.find('textarea').attr('name',newname + );  

updated fiddle : http://jsfiddle.net/ny5y7/


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -