编辑
我不明白为什么人们在没有实际尝试问题的情况下投反对票。我将重写这个问题,试图更清楚地解释我自己。对不起,如果我错误地解释了我自己。
我有一个简单的 hello world 页面:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div id="c">
<div data-role="page">
<div data-role="header"> <h1 style="font-size: 150%;"> My Title </h1></div>
<br /> <br />
<div data-role="Number">
<p>
<h1 style="text-align: center; font-size: 310%;">
Hello Wold</h1>
</p>
</div>
</div>
</div>
</body>
</html>
它呈现如下:
(这就是为什么我标记它 jquery 我想要 jquery 的外观和感觉)
请注意页面呈现良好。问题是我想动态放置那个html。我在 ajax 的帮助下获得了以下内容:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div id="c">
<!-- Content will be replaced -->
</div>
<script type="text/javascript">
$.ajax({
url: 'someUrl',
success: function (result) {
// result should equal =
result= '<div data-role="page"> <div data-role="header"> <h1 style="font-size: 150%;"> My Title </h1></div> <br /> <br /> <div data-role="Number"> <p> <h1 style="text-align: center; font-size: 310%;"> Hello Wold</h1> </p> </div> </div>';
$('$c').append( result );
}
});
</script>
</body>
</html>
如果我运行,什么都不会渲染!我想知道哪个 jquery 函数负责为 html 设置样式。一旦我的 ajax 响应返回,我想再次执行它。