Home > Article > Web Front-end > javascript delete html tag function cIsHTML
Core function code:
function cIsHTML(str) { // parseHTML 会解析页面中的代码,故放弃此方法实现 //try { // $.parseHTML(str); // } catch (e) { // return { // errno: e.name, // errmsg: e.message // }; // } // return true; if (/\s?<!doctype html>|(<html\b[^>]*>|<body\b[^>]*>|<x-[^>]+>)+/i.test(str)) { return true; } return { errno: 'Invalid Html code', errmsg: 'Invalid Html code' }; }
For detailed information on jQuery.parseHTML() function, please view this article: jQuery.parseHTML() function detailed explanation
For more javascript deletion html tag function cIsHTML related articles, please pay attention to the PHP Chinese website!