Question: I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.

```
$("#tab-dock").append('<div id="daccordion">')

$("#daccordion").append('<div id="dinfo"><h3><a href="#">Info</a></h3>')
$("#dinfo").append('<div>Some info about this location.</div>')
$("#daccordion").append('</div>')

$("#daccordion").append('<div id="dmarket"><h3><a href="#">Market</a></h3>')
$("#dmarket").append('<div>Market info would go here!</div>')
$("#daccordion").append('</div>')

$("#tab-dock").append('</div>')

$("#daccordion").accordion({ header: "h3",navigation: true });

```

I have another Accodion which was created normally and it works fine. I just can't get them to match up though. Any ideas? Thanks!

Edit: Thanks for all of the suggestions, learned quite a bit just from them. The problem turned out to be due to size, I had to call the Accordion's resize to get it working.

Answer: 
Seems like your examples formatted with three digits groups except last, you can write a simple function, uses thousand seperator and adds last digit:

```
>>> def phone_format(n):                                                                                                                                  
...     return format(int(n[:-1]), ",").replace(",", "-") + n[-1]                                                                                                           
... 
>>> phone_format("5555555")
'555-5555'
>>> phone_format("5555555")
'555-5555'
>>> phone_format("5555555555")
'555-555-5555'
>>> phone_format("18005555555")
'1-800-555-5555'

```
A simple solution might be to start at the back and insert the hyphen after four numbers, then do groups of three until the beginning of the string is reached. I am not aware of a built in function or anything like that.

You might find this helpful:
<http://www.diveintopython3.net/regular-expressions.html#phonenumbers>

Regular expressions will be useful if you are accepting user input of phone numbers. I would not use the exact approach followed at the above link. Something simpler, like just stripping out digits, is probably easier and just as good.

Also, inserting commas into numbers is an analogous problem that has been solved efficiently elsewhere and could be adapted to this problem.