Could use a little help with this, it seems like there should be a cleaner way to write this out.
I want to select each text input in the #endowment div, that is not empty. Also, I am writing to a div called 'dyn_hidden', that I want to append each input with a value in it. So on each blur I'm deleting everything, and then adding each one back. Is there a better way for this?
Thanks!
jQuery("#endowment input[type='text']").blur( function() {
// Empty out dyn_hidden div
jQuery('#dyn_hidden').html('');
jQuery("#endowment input[type='text']").each(function() {
if(jQuery(this).val() !== "") {
end_fund = '<input type="hidden" name="fund[]" value="'+jQuery(this).attr('title')+'">';
end_amount = '<input type="hidden" name="amount[]" value="'+jQuery(this).val()+'">';
jQuery('#dyn_hidden').append(end_fund, end_amount);
}
});
});