Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 输入类型为“的jQuery”;“数字”;_Javascript_Jquery - Fatal编程技术网

Javascript 输入类型为“的jQuery”;“数字”;

Javascript 输入类型为“的jQuery”;“数字”;,javascript,jquery,Javascript,Jquery,这个问题很简单,但我正在寻找正确的方法来处理这个问题 我已经把它分解成一个最简单的例子,它仍然显示了这个问题 假设我有一个基本的HTML表: <table id="customerTable"> <caption class="bg-primary h4">Customer Overview</caption> <thead> <tr> <th>Customer ID&

这个问题很简单,但我正在寻找正确的方法来处理这个问题

我已经把它分解成一个最简单的例子,它仍然显示了这个问题

假设我有一个基本的HTML表:

<table id="customerTable">
    <caption class="bg-primary h4">Customer Overview</caption>
    <thead>
        <tr>
            <th>Customer ID</th>
            <th>Customer Name</th>
            <th># Projects</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Enterprise Management</td>
            <td>14</td>
        </tr>
        <tr>
            etc ...
        </tr>
    </tbody>
</table>
问题是,当用户在数字字段中键入一个数字时,它会按预期工作。但是,如果他们随后将焦点更改为另一个输入,CSS将恢复

如果他们使用数字上/下选择器,则在控件失去焦点后更改仍然存在


当手动输入jQuery选择器以使其在失去焦点时停止恢复时,我缺少了什么?我尝试了各种
聚焦
事件、
模糊
等,但找不到一个能改变这种行为的事件。

@Rayon Dabre很快回答了这个简单、快速的问题

$('#colorColumnRed').bind('input')

$(“#colorColumnRed”).bind('input'
)怎么样?你可以上传一个plunkr吗?如果我不理解确切的问题的话。@RayonDabre就是这个问题,谢谢。
$(function () {

   $('#colorColumnRed').bind('change keyup', function () {
        var colId = $('#colorColumnRed').val();
        $('#customerTable td:nth-child(' + colId + ')').toggleClass('redText');
    });

});
$('#colorColumnRed').bind('input')