Cita:
Iniciado por Panino5001 Fijate si te sirve
Muchas gracias.
Funciona muy bien si los comentarios están ANTES del JS.
Pero aki no retorna:
Código:
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<p>Cantidad de info...</p>
<script type="text/javascript">
function htmlTree(obj){
var str = "";
if (obj.hasChildNodes()) {
var child = obj.firstChild;
while (child) {
if (child.nodeType === 8) {
str +=child.nodeValue + '\n';
}
if (child.nodeType === 1) {
str += htmlTree(child);
}
child = child.nextSibling;
}
}
return str;
}
alert(htmlTree(document.documentElement));
</script>
<!-- hola -->
<p>Cantidad de info...</p>
<!-- chau -->
</body>
</html>