Home > Web Front-end > JS Tutorial > body text

javascript delete html tag function cIsHTML

高洛峰
Release: 2017-01-11 09:23:25
Original
1126 people have browsed it

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: &#39;Invalid Html code&#39;,
                errmsg: &#39;Invalid Html code&#39;
            };
    }
Copy after login

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!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!