如何应用我的代码以使用 Ctrl+A 全选

How to apply my code for use Ctrl+A for select All?

本文关键字:Ctrl+A 全选 代码 我的 何应用 应用      更新时间:2023-09-26

如何应用我的代码用于全选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) {

删除此行

event.preventDefault();