jquery Inheritance Extend usage

Source: Internet
Author: User
Tags diff

/直接基于jQuery的扩展,判断是否为空 $.isBlank = function (obj){    return ( typeof (obj)== ‘undefined‘ ||obj== ‘‘ ||obj== null );   } //直接基于jQuery的扩展,去除html标签,保留内容   $.htmlContent = function (tag){    var reTag = /<(?:.|\s)*?>/g;    return tag.replace(reTag, "" );   } //直接基于jQuery的扩展(方式二) $.xy = { sayhello: function (){ return "hello" ;}, saybaybay: function (){ return "baybay" ;} }; //jQuery类级别的扩展 $.extend({ add: function (a,b){ return a+b;}, diff: function (a,b){ return a-b} }); //jQuery对象级别的扩展 $.fn.extend({   getvalue: function (){   return this .val();    }   }); HTML code < body >   < script type = "text/javascript" >    document.write("判断是否为空:"+$.isBlank(null));   </ script >   < span class = "myspan" ></ span >   < script type = "text/javascript" >    document.write("过滤html标签:"+$.htmlContent("< html >< body >< a id = ‘a1‘ >a标签</ a >< div style = ‘width:100%‘ >div标签</ div >内容</ body ></ html >")+"< br />");    document.write("扩展自jQuery类的xy的sayhello方法:"+ $.xy.sayhello()+"</ br >");    document.write("扩展自jQuery类的xy的sayhello方法:"+ $.xy.saybaybay()+"</ br >");    document.write("基于jQuery类的add法:"+ $.add(3,5)+"</ br >");    document.write("基于jQuery类的diff法:"+ $.diff(5,3)+"</ br >");    document.write("基于自jQuery类对象的扩展getvalue():"+$("< input type = ‘text‘ value = ‘str‘ />").getvalue()+"< br />");   </ script >   </ body >

jquery Inheritance Extend usage

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.