html - Trying to repeat a field with iterating names in jQuery -


the html

<div class="repeatable">   <a href="#" class="more">more</a>   <fieldset class="intro_clergy_">       <label>title</label>       <input class="title_" type="text" name="intro_clergy_title_1" /><br />        <label>name</label>       <input class="name_" type="text" name="intro_clergy_name_1" />   </fieldset> </div> 

the jquery

$('.repeatable').each(function(){     var group = this;      var namestructure = $(" > fieldset", group).attr("class");      $(" > .more", this).click(function(){         $(" > fieldset", group).clone().appendto(group).children().attr("name", namestructure + $(this).attr("class") + "1");         return false;     })   }) 

so trying whenever clicks "more" button, adds new field. have working except need take class name of fieldset , input , insert input name. if @ tried do, know got intro_clergy_more, because this more link. need trying figure out how can call input.

are looking this?

$('.repeatable').each(function(){     var group = this;      var namestructure = $(" > fieldset", group).attr("class");      $(" > .more", this).click(function(){         $(" > fieldset", group).clone().appendto(group)             .children("input").each(function(){                 $(this).attr("name", namestructure + $(this).attr("class") + "1");             })         return false;     }) }) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -