So I have been looking for this question around and still didn't find an answer. I know how to add a single space with the append method in jQuery but don't know how to add multiple spaces.
Example:
<div id="#myDiv"> hey? <span class="space"></span> my name<span class="space"></span> is coding enthusiast<span class="space"></span> .....</di>
I want the output to be like this:
Hey my name is coding enthusiast ......
I have tried Jquery append, it gives me nothing like that.
//1st try
$('space').append(" ");
//2nd try
$('space').append("       ");
//2nd try output: hey   my name   is coding enthusiast   ....
I feel like I am missing something small. Any ideas?
Edit: Had a typo in my code's question which misled some people when answering:
//1st try
$('.space').append(" ");
//2nd try
$('.space').append("       ");
//2nd try output: hey   my name   is coding enthusiast   ....
fixed, forgot semicolon, Thanks to Jake's comment(which he deleted already), I could fix this issue.
$('.space').append(" ");
You are not selecting your elements correctly and add semicolon. Try this:
$('.space').append(" ");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With