这是这个问题的后续问题:
当文本框获得焦点时选择文本框的所有内容(Javascript 或 jQuery)
基本上我将文本框与jQuery 屏蔽输入插件(编辑:链接可能不再指向相关版本)
当屏蔽的输入文本框接收焦点时,我想选择该文本框的所有内容,但似乎将该插件绑定到文本框会阻止这种情况。我只是想知道是否有办法解决这个问题。
下面是演示该问题的示例 .html 页面:
<html>
<head>
<title></title>
</head>
<body>
<input id="masktest" type="text" value="01/01/2009" />
<br />
<input id="focustest" type="text" value="on focus will select all contents..." />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://jquery-joshbush.googlecode.com/files/jquery.maskedinput-1.2.1.pack.js"></script>
<script type="text/javascript">
$(function() {
$("#masktest").mask("99/99/9999");
// Contents of textboxes will be selected when receiving focus.
$("input[type=text]")
.focus(function() {
$(this).select();
});
});
</script>
</body>
</html>
我是该书的作者屏蔽输入插件对于 jQuery。我决定这应该是已完成蒙版的默认行为,并将其纳入最新版本。您可以阅读详情here
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)