简体   繁体   English

TypeError:$(…).mask不是asp.net c#中的jQuery函数

[英]TypeError: $(…).mask is not a function by jquery in asp.net c#

I am doing one task in that I am doing jquery masked for date but when I am running this task in html it work very well but in asp.net it shows the issues that is mask is not a function. 我正在执行一项任务,因为我正在对日期进行屏蔽的jquery,但是当我在html中运行此任务时,它工作得很好,但是在asp.net中,它显示了掩模不是功能的问题。

here is my code 这是我的代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.10/jquery.mask.js"></script>

<asp:Label ID="Label4" Text="Birth Date :" runat="server"></asp:Label>&nbsp;&nbsp;
<input type="text" id="date"/>

$(document).ready(function () {
        $('#date').mask("99/99/9999");
    });

Thank You. 谢谢。

This may causes two scenario one is your server may slow to fetch the mask plugin from cdn, to avoid this access the file from local. 这可能导致两种情况:一种是您的服务器可能会缓慢地从cdn获取mask插件,以避免这种从本地访问文件的情况。 second one is you placed that on ready function, sometimes ready function execute before the js file load. 第二个是将其放置在ready函数上,有时ready函数在js文件加载之前执行。 So change ready function to onload function or try with some setTimeout function but it is not correct way, setTimeout function helps to identify the second scenario issue. 因此,将ready函数更改为onload函数或尝试使用某些setTimeout函数,但这不是正确的方法,setTimeout函数有助于识别第二种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM