XIYUETA.COM
源代码:
点击运行
<script src="https://www.xiyueta.com/js/xiyueta.min.js?v36"></script> <script> /* $.load() 加载解析HTML .not() 从匹配的元素集中删除元素 .css() 获取匹配元素集中第一个元素的CSS属性值,或者为每个匹配元素设置一个或多个CSS属性 $.html 打印HTML对象全部内容,与cheerio库里使用一致 $.log() 在浏览器里显示内容 == document.write() */ var html = [ '<style>', ' div {', ' width: 50px;', ' height: 50px;', ' margin: 10px;', ' float: left;', ' background: yellow;', ' border: 2px solid white;', ' }', ' .green {', ' background: #8f8;', ' }', ' .gray {', ' background: #ccc;', ' }', ' #blueone {', ' background: #99f;', ' }', ' </style>', '<div></div>', '<div id="blueone"></div>', '<div></div>', '<div class="green"></div>', '<div class="green"></div>', '<div class="gray"></div>', '<div></div>' ].join("\n"); xiyueta.load(html) document.write(xiyueta.html()) $( "div" ).not( ".green, #blueone" ) .css( "border-color", "red" ); $.log(xiyueta.html()) document.write(xiyueta.html()) </script>
运行结果