-

xiyueta().printAll() 属性方法

打印匹配元素集中全部元素的HTML内容
快速上手

xiyueta().printAll()属性方法 两种调用方式:
1、xiyueta().printAll(); //打印匹配元素集中全部元素的HTML内容
2、xiyueta().printAll(param); //参数分列为 format格式化HTML内容,zip压缩HTML内容,color给html着色,多个选项可以合在一起使用,以,句号或|符号分开

总结:xiyueta().printAll()类似于cheerio库的$.html(),在xiyueta.js库里也可以用$.html()来打印全部html,或使用xiyueta().printAll()来打印全部html

尝试一下>>

  • 代码
  • 效果
<script src="https://www.xiyueta.com/js/xiyueta.min.js"></script>
<script>var html = "<body>aaa<div>xiyueta<div>\n作者<div style='color:red'>小云\n</div></div></div><div>网址:xiyueta.com</div>bbbb</body>"
$.load(html); //解析html 
 
document.write($("div").printAll("format|color"));
</script>
<div>xiyueta
    <div>作者
        <div style="color:red">小云</div>
    </div>
</div>

<div>作者
    <div style="color:red">小云</div>
</div>

<div style="color:red">小云</div>

<div>网址:xiyueta.com</div>