JS for extend and fn.extend use

Source: Internet
Author: User

$.fn.extend extension is a jquery object function, $.extend extension is a jquery global function

<! DOCTYPE Html>"UTF-8"><title>insert title Here</title><script type="Text/javascript"Src=".. /.. /resources/js/jquery-2.0.0.js"></script><script type="Text/javascript"Src=".. /.. /resources/customjs/regexp.js"></script>" Time"Type="Button"Name=" Time"Value="Enter Date"/><br/><input id="AddData"Name=""Type="Button"Value="Add Data"/></body><script type="Text/javascript">$("#time"). Click (function () {varInputdate = Prompt ("Please enter the date:"); varFlag =validate.validatedate (inputdate); Console.log (flag);}); $("#addData"). Click (function () {//$.fn.extend jquery Object Functions$( This). inputdatatohtml (); });//jquery Global Functions$.inputdataastitle ();</script>

Regexp.js

varValidate = {    //Verify the date formatted as YYYY-MM-DDvalidatedate:function (inputdate) {varR = Inputdate.match (/^ (\d{1,4}) (-|\/) (\d{1,2})\2(\d{1,2})$/); if(r==NULL)             return false; varD=NewDate (r[1], r[3]-1, r[4]); return(D.getfullyear () ==r[1]&& (D.getmonth () +1) ==r[3]&&d.getdate () ==r[4]); }}$.fn.extend ({inputdatatohtml:function () {vardata = prompt ("Please enter data:"); if($("#list"). length==0&&$ ("#list ol"). length==0){            $( This). After ("<div id= ' list ' ></div>"); $("#list"). Append ("<ol></ol>"); }        $("#list ol"). Append ("<li>"+data+"</li>"); }}) $.extend ({inputdataastitle:function () {vardata = prompt ("Please enter a title:"); $("Body"). Append (""+data+"</font>"); }});

JS for extend and fn.extend use

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.