Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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 Not运算符用于使用keyup运算符_Javascript_Jquery - Fatal编程技术网

Javascript Not运算符用于使用keyup运算符

Javascript Not运算符用于使用keyup运算符,javascript,jquery,Javascript,Jquery,我有一个带有几个打开的文本框的表。其中一个框将自动填充为100,我已将其设置为只读。我希望如果受访者在任何其他框中输入100,我会发出警报并清除该值。这对我有用。但是,我只想将此警报功能用于非自动填充和只读的文本框。不确定是否正在使用:运算符不正确或不正确。Rest脚本正在工作 下面是我的脚本 $(document).ready(function(){ $('tr td').each(function(){ if($(this).children('input').val()=='1

我有一个带有几个打开的文本框的表。其中一个框将自动填充为100,我已将其设置为只读。我希望如果受访者在任何其他框中输入100,我会发出警报并清除该值。这对我有用。但是,我只想将此警报功能用于非自动填充和只读的文本框。不确定是否正在使用:运算符不正确或不正确。Rest脚本正在工作

下面是我的脚本

$(document).ready(function(){
  $('tr td').each(function(){
    if($(this).children('input').val()=='100')
      $(this).children('input').prop('readOnly',true);
  });
  $('input:text:not(readonly)').on('keyup',function(){
    if($(this).val()=='100')
    {
      alert("Please provide answer between 0-99.");
      $(this).val("");
    }
  });
});
中使用:而不是

$('input:text:not([readonly])').on('keyup',function(){
 if($(this).val()=='100')
 {
   alert("Please provide answer between 0-99.");
   $(this).val("");
 }
});

应该适用于readonly=true和readonly=readonly

谢谢,但是它对我不起作用..当我要使用tab键读取只读文本时..它仍然会给我提示并删除管道值。@Vaibhav:你能分享演示吗。还可以尝试使用
:not([readonly])
$('input:not([readonly])')