Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Matt Campbell9,767 Points
Adding HTML to stuff with jQuery - I'm stuck!!!
I've been making a countdown timer.
That's the code. There's jQuery there which I've just learnt and I have no idea if it's correct because I've never come across it before but, it works, at least it does outside of codepen.io. Don't know why, but half the stuff I put in codepen doesn't work. Anyway...
What I'm after knowing is this.
There's 4 blue boxes with numbers in, as we can see. What I'd like to do is make that 8 boxes. Each digit in its own box with a slight gap between digits to make up a number. Because jQuery populates these numbers, there's nothing to grab hold of and make changes to. It needs to be done with jQuery but I don't know how or have the first idea where to start.
Hoping for some help! Thanks.
Tagging Andrew Chalkley for this one...hoping for an appearance on the forum! ;)
Andrew ChalkleyTreehouse Guest Teacher
To get code pen to work. Click the cog and select the latest version of jQuery.
As for your other issue, you can convert the number to a string and then "split" it.
Here's an example.
(27 + "").split("")
This would result in the array of
Here's the same code split over multiple lines.
var number = 27; var convertedNumberToString = number + ""; var arrayOfCharacters = convertedNumberToString.split("") arrayOfCharacters; //"2" arrayOfCharacters; //"7"
Hope that helps :)