Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addLocation() {
- var a = $( '.add-location' );
- a.on('click', function() {
- var item = $('.location-counter');
- var counter = item.length;
- var newCounter = new Number(counter + 1);
- var cloned = $('.location-' + counter).clone().attr('class', 'location-counter inputs location-' + newCounter).fadeIn('slow');
- var checkboxId = $(this).attr('id');
- var inputName = $(this).attr('name');
- var labelFor = $(this).attr('for');
- cloned.find('input[type="checkbox"]').each(function() {
- var checkboxId = $(this).attr('id');
- $(this).attr('id', checkboxId + '-' + newCounter);
- });
- cloned.find('input').each(function() {
- var inputName = $(this).attr('name');
- $(this).attr('name', inputName + '-' + newCounter);
- });
- cloned.find('label').each(function() {
- var labelFor = $(this).attr('for');
- $(this).attr('for', labelFor + '-' + newCounter);
- });
- $('.location-' + counter).after(cloned);
- });
- }
- addLocation();
Advertisement
Add Comment
Please, Sign In to add comment