Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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中启用和禁用textfield_Javascript_Jquery - Fatal编程技术网

Javascript 在jquery中启用和禁用textfield

Javascript 在jquery中启用和禁用textfield,javascript,jquery,Javascript,Jquery,需要解决如何在文档准备就绪时使用jquery启用和禁用文本字段的问题。 我尝试过的示例代码如下,但没有得到任何输出,也没有显示警报 jQuery(document).ready(function(){ /*jQuery('#tan label.control input').change();*/ }); jQuery("#cca label.control input").on('change', function (event) { alert('I am pretty sur

需要解决如何在文档准备就绪时使用jquery启用和禁用文本字段的问题。 我尝试过的示例代码如下,但没有得到任何输出,也没有显示警报

jQuery(document).ready(function(){
     /*jQuery('#tan label.control input').change();*/
});
jQuery("#cca label.control input").on('change', function (event) {
  alert('I am pretty sure the text box changed');
  event.preventDefault();
});
试试这个:

jQuery(document).ready(function(){
     jQuery("#cca label.control input").on('change', function (e) {
    alert('I am pretty sure the text box changed');
    e.preventDefault();
  });
});

如果这不起作用,那么请在键入
jQuery(“cca label.control input”)时用控制台返回的内容进行响应。length

您缺少
Query(document)中的
j
。ready(function(){/code>。您可以共享HTML代码吗?您的第一个单词是“Query”还是“jQuery”(必须是后者)这是我的脚本代码jQuery(“cca”).change(函数(){alert('I'm prevent the text box changed');});我没有得到弹出窗口,在控制台中得到这个错误andy“event.returnValue已弃用。请改用标准event.preventDefault()。”请尝试我编辑过的答案。您使用的jQuery版本是什么?