我正在尝试使用屏蔽输入使我的日期看起来像 9999-99-99,但似乎没有任何影响。我不知道我做错了什么。
<script type="text/javascript" src="http://digitalbush.com/wp-content/uploads/2013/01/jquery.maskedinput-1.3.1.min_.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
jQuery(function ($) {
$("#date").mask("9999-99-99");
});
</script>
http://jsfiddle.net/doitlikejustin/xw2je/3/
这是我的输入框-
<input name="date" type="text" id="date" value="<?php echo $_SESSION['date'];?>" />
最佳答案
您需要首先包含 jQuery 脚本。
顺序很重要,因为 jQuery Masked 输入插件依赖于 jQuery。您应该告诉浏览器首先加载 jQuery,然后只有您可以处理 jQuery 内容。
例如(我测试过这个):
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://digitalbush.com/wp-content/uploads/2013/01/jquery.maskedinput-1.3.1.min_.js"></script>
<script type="text/javascript">
jQuery(function ($) {
$("#date").mask("9999-99-99");
});
</script>
</head>
<body>
<input name="date" type="text" id="date" value="" />
</body>
</html>
我希望这会有所帮助。
关于javascript - 屏蔽输入插件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18296578/