<div id="myDiv" class=" blueberry mango "></div>
If we use the .addClass()
$("#myDiv").addClass("carrot");
The class for myDiv is now "(no-space)blueberry mango(double-space)carrot"
There is a left-trim, but there are double spaces between mango and carrot because there were no right-trim
- Is there a particular reason why jQuery’s
addClass()is not
right-trimming? - Or the left-trim was not even intended?
Seems like jQuery is doing the trim after adding the class. See jquery addclass code below,
So it’s like below,
jQuery.trim(" blueberry mango " + " " + "carrot")