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
Post a Comment