Skip to content

Instantly share code, notes, and snippets.

@leongaban
Last active August 29, 2015 14:04
Show Gist options
  • Save leongaban/e9bd67d5d40d4b0792b3 to your computer and use it in GitHub Desktop.
Save leongaban/e9bd67d5d40d4b0792b3 to your computer and use it in GitHub Desktop.
.each to create Objects (jQuery)
addedPhones = $('.added_phone');
addedPhones.each( function(i) {
var tag = $(this).children("label").text();
var value = $(this).children("input").val();
phoneObjs = $(this).map(function(i,el) {
var $el = $(el);
return {
label: value,
tag: tag
}
}).get();
params.phones = params.phones.concat(phoneObjs);
});
<div class='removeable'>
<li class='added_phone'>
<label>" +labelText+ "</label>
<span> Phone</span>
<br/>
<input class='new_phone' type='tel' pattern='[0-9]{10}' name='" +nameText+ "' value='' autocomplete='off' maxlength='20' />
<div class='remove_info'></div>
</li>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment