Revision: 52482
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at October 25, 2011 00:18 by jbernus
                            
                            Updated Code
$('ul li').each(function(index) {
	var spanContent = $(this).children('span').html(),
	spanContent = spanContent.toLowerCase().replace(/ /g, '-');
	$(this).children('input').attr('id', 'input-'+spanContent);
	$(this).children('span').wrapInner('<label for="input-'+spanContent+'"/>');
});
<ul>
<li><input type="checkbox" name="input-name-1" value="" /><span>Description 1</span></li>
<li><input type="checkbox" name="input-name-2" value="" /><span>Description 2</span></li>
<li><input type="checkbox" name="input-name-3" value="" /><span>Description 3</span></li>
</ul>
                                
                            Revision: 52481
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at October 25, 2011 00:11 by jbernus
                            
                            Initial Code
$('ul li').each(function(index) {
	var spanContent = $(this).children('span').html(),
	spanContent = spanContent.toLowerCase().replace(/ /g, '-');
	$(this).children('input').attr('id', 'input-'+spanContent);
	$(this).children('span').wrapInner('<label for="input-'+spanContent+'"/>');
});
                                Initial URL
Initial Description
Dynamically add <label> HTML tag to input description, matching the input by adding an ID value to the input.
Initial Title
Add \'label for\' matching input dynamically
Initial Tags
form, javascript, html, jquery
Initial Language
jQuery