Welcome to the Treehouse Community
Looking to learn something new?
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 :)