jquery intercepts strings, date strings to date, gets plain text in HTML

Source: Internet
Author: User

jquery intercepts strings, date strings to date, and gets plain text in Html.

varcom = com | | {};(function($, Com) {/** Intercept String * @param str: string to intercept * @param len: how many characters are reserved * @param symbol: The character to be added after the end of the string*/Com.cutstr=function(str, len, Symbol) {if(symbol = =Undefined) {symbol= "..."; } Len= Len | | 25; varresult =str; if(str) {if(str.length && str.length >Len) Result= str.substr (0, Len) +symbol; }        returnresult; },    /** Convert date string to date * (E.G. convert "2016-12-24 20:13:14" to date Format) * @param D: string to be converted (the time passed cannot have Milliseconds)*/com.getdate=function(d) {//Some browsers (IE) do not support the date format "YYYY-MM-DD hh:mm:ss", You must convert "-" to "/"        varDate =NewDate (date.parse (d.replace (/-/g, "/"))); returndate; },    /** Get plain text of HTML code * @param HTML*/Com.removehtmltag=function(HTML) {html= Html.replace (/<\/?[ ^>]*>/g, ");//Remove HTML tagHTML = html.replace (/[|) *\n/g, ' \ n ');//Remove line trailing blanks        //html = html.replace (/\n[\s| |) *\r/g, ' \ n '); Remove extra empty lineshtml = html.replace (/&nbsp;/ig, ");//Remove &nbsp;html = html.replace (/\s/g, ");//Remove a space        returnhtml; }}) (jQuery, com);

jquery intercepts strings, date strings to date, gets plain text in HTML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.