如何应用我的代码以使用 Ctrl+A
来选择全部?
http://jsfiddle.net/Fp4sJ/806/
首先,在输入框中填入数字EG: 333.44
,然后按Ctrl+A键。
为什么不选择输入中的所有数据,我该如何申请?
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(window).load(function(){
$(".allownumericwithdecimal").on("keypress keyup blur",function (event) {
//this.value = this.value.replace(/[^0-9\.]/g,'');
$(this).val($(this).val().replace(/[^0-9\.]/g,''));
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});
});
</script>
<input type="text" name="numeric" class='allownumericwithdecimal'>
最佳答案
从此处的事件中删除“keyup”触发器:
$(".allownumericwithdecimal").on("keypress keyup blur",function (event) {
就这样吧
$(".allownumericwithdecimal").on("keypress blur",function (event) {
关于javascript - 如何应用我的代码以使用 Ctrl+A 来选择全部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27264434/