Home  >  Article  >  Web Front-end  >  javascript delete html tag function cIsHTML

javascript delete html tag function cIsHTML

高洛峰
高洛峰Original
2017-01-11 09:23:251087browse

Core function code:

function cIsHTML(str) {
        // parseHTML 会解析页面中的代码,故放弃此方法实现
        //try {
        //  $.parseHTML(str);
        // } catch (e) {
        //  return {
        //      errno: e.name,
        //      errmsg: e.message
        //  };
        // }
        // return true;
         
        if (/\s?|(]*>|]*>|]+>)+/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!


Statement:
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