I have a page of categories, when the user clicks one, the items under that category are loaded via a jQuery Ajax call, in a table, and stuck into an element just below the
I used an answer from another post Remove whitespace and line breaks between HTML elements using jQuery where there was a script which was more effective than the one above. I used the answer to solve it, but I will repeat it for a complete answer.
jQuery.fn.htmlClean = function() {
this.contents().filter(function() {
if (this.nodeType != 3) {
$(this).htmlClean();
return false;
}
else {
return !/\S/.test(this.nodeValue);
}
}).remove();
return this;
}
Ultimately, this is only an interim solution and should be fixed in IE9/10 by Microsoft.