$(":mobile-pagecontainer").pagecontainer() not working as expected

$(":mobile-pagecontainer").pagecontainer() not working as expected

HI

I have an HTML page with two JQM pages
<div data-role="page" id="page1">
.
.
.
</div>

...and 
<div data- role="page"id="page2">
.
.
.</div>

From "page1" I have an  <a> link to page 2 and it works fine href="#page2"

I also have a  <button> with a onclick() function which calls the pagecontainer change method, page 2 shows briefly then page1 returns

Why does page 2 show permanently ?

Any help would be useful

Thanks

Nigel