简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <meta charset="utf-8"> <link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/> <script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script> <script src="http://cdn.static.twle.cn/libs/jquery/2.2.0/jquery.min.js"></script> <script> $(function() { var panything = "[\\w\\W]*?", // 空白 pspace = "[\\x20\\t\\r\\n\\f]", // 标签结尾(whitespace or greater-than) pnameEnd = pspace.replace( "]", ">]" ), // 标签名 // https://html.spec.whatwg.org/multipage/syntax.html#tag-open-state // https://html.spec.whatwg.org/multipage/syntax.html#tag-name-state pname = "[a-z]" + pnameEnd.replace( "[", "[^/\\0" ) + "*", // 空元素 // https://html.spec.whatwg.org/multipage/syntax.html#void-elements pvoidName = "(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|" + "source|track|wbr)(?=" + pnameEnd + ")", // 属性 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 pattrs = "(?:" + pspace + "+[^\\0-\\x20\\x7f-\\x9f=\"'/>]+(?:" + pspace + "*=" + pspace + "*(?:\"" + panything + "\"|'" + panything + "'|" + pnameEnd.replace( "[", "[^" ) + "*(?!/)" + ")|))*" + pspace + "*", // 关闭标签的尾随内容 pcloseTail = "(?:" + pspace + panything + "|)", rspecialHtml = new RegExp( // 自关闭的非空元素: $1–$5 "(<)(?!" + pvoidName + ")(" + pname + ")(" + pattrs + ")(\\/)(>)|" + // 非 HTML容器 (element, comment, 或者 CDATA): $6 "(<(script|style|textarea)" + pattrs + ">" + panything + "<\\/\\7" + pcloseTail + ">|" + "<!--" + panything + "--)", "gi" ), pspecialReplacement = "$1$2$3$5$1$4$2$5$6"; $.htmlPrefilter = function( html ) { return ( html + "" ).replace( rspecialHtml, pspecialReplacement ); }; var htm = '<a /><meta>1516</meta>'; alert($.htmlPrefilter(htm)); alert(htm); }); </script> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer>
运行结果: