我认为 WP8 上的 IE10 无法打印“rec”对象的内容,即使实际上添加了“li”元素。我尝试使用带有 jQuery(v1.7.1)的 Cordova(v2.4.0)windows phone 8 应用程序,它似乎可以使用以下代码
$.each(lis, function (ind, rec) {
console.log(rec.innerHTML.toString());
});
输出如下:
ScriptNotify :: first
ScriptNotify :: second
ScriptNotify :: third
做 outerHTML 代替打印:
ScriptNotify :: <li data-test="test1">first</li>
ScriptNotify :: <li data-test="test2">second</li>
ScriptNotify :: <li data-test="test3">third</li>
来自 index.html 的完整代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<ul id="here">
</ul>
</div>
<script type="text/javascript" src="lib/jquery-1.7.1.js"></script>
<script type="text/javascript" src="cordova-2.4.0.js"></script>
<script>
window.console = {
log: function (str) { window.external.Notify(str); }
};
$('#here').append('<li data-test="test1">first</li>');
$('#here').append('<li data-test="test2">second</li>');
$('#here').append('<li data-test="test3">third</li>');
var lis = $('#here').find('li');
console.log(lis.length.toString());
$.each(lis, function (ind, rec) {
console.log(rec.outerHTML.toString());
});
</script>
</body>
</html>