2

I try to add a DIV to the body, but I obtained a blank page. This is my example.

In the same example I uncommented the HTML because is working fine.

Code :

$("body").append('<div data-role="page"><div data-role="content">HOME</div></div>');
$("body").collapsibleset();
2
  • If you inspect the HTML using FireBug or Chrome's debugger, you can see that the div is being added, it's just not showing up in the jsFiddle window. Commented Mar 20, 2013 at 22:11
  • I understand, but why ? I have the same problem in my browser.. Commented Mar 20, 2013 at 22:13

3 Answers 3

2

This doesn't work because data-role= "page" has a display of none.
enter image description here

I don't know where this css if coming from, but if you disable it as I did, "Home" shows up

EDIT This css is coming from jquery mobile. You could either manually set the css for data-role="page" to display:block; in your stylesheet to override jquery, or you don't even have to assign it in the HTML.

Sign up to request clarification or add additional context in comments.

Comments

2

I added an ID to the page and invoked the show() mothod of jquery. It worked

$("body").html('<div data-role="page" id="myPage"><div data-role="content"><p>HOME</p> </div></div>');
$("#myPage").show();

Please check out the fiddle at http://jsfiddle.net/cFens/2/

Comments

0

You should uncheck jQuery Mobile 1.1.1 and check something else like jQuery UI 1.8.18 in the jsFiddle

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.