How to add space after elements added via jQuery
- by ahsteele
I am rendering a similar construct to the below with some server side code. The server side code inserts hard returns in between the project label and text fields. Not a big deal except the below jQuery code inserts the project label and text fields mashed together.
var projectLabel = $('<label for="project">Project</label>');
var projectField = $('<input type="text" name="project" id="projectName" />');
projectLabel.insertBefore($(this));
projectField.insertBefore($(this));
Because of this discrepancy the elements rendered server side have a space between them while the ones rendered on the client do not. I've tried adding a nbsp; at the end of each line to no avail. Unfortunately, I have been unable to remove the hard returns outputted by the server side code. Further because of the space I can't fix this with CSS. What are my options for adding spacing via jQuery?