Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.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中不起作用_Javascript_Twitter Bootstrap_Disabled Input_Input Field - Fatal编程技术网

为引导文件样式输入设置禁用在javascript中不起作用

为引导文件样式输入设置禁用在javascript中不起作用,javascript,twitter-bootstrap,disabled-input,input-field,Javascript,Twitter Bootstrap,Disabled Input,Input Field,我想使用以下代码禁用输入,当使用引导文件样式按下按钮时会调用该代码(作为参考,我使用了此链接 ): 输入定义如下: <input type="file" class="filestyle" required="required" data-buttontext="Browse for new script"> 但是当调用disableInput时,输入不会被禁用,也不会变灰,并且在单击“浏览新脚本”时仍会触发文件选择器,即使在调试时我可以看到它被调用 设置输入的data dis

我想使用以下代码禁用输入,当使用引导文件样式按下按钮时会调用该代码(作为参考,我使用了此链接 ):

输入定义如下:

<input type="file" class="filestyle" required="required" data-buttontext="Browse for new script">

但是当调用disableInput时,输入不会被禁用,也不会变灰,并且在单击“浏览新脚本”时仍会触发文件选择器,即使在调试时我可以看到它被调用

设置输入的
data disabled=“true”
属性可以工作,就像文档中“disabled”下提供的示例代码一样,但这不是我需要的


知道我哪里出错了吗?

这是医生关于禁用输入的说法:

Enables or disables the input text. Type: Boolean, Default: true
Via JavaScript:

  $(":file").filestyle({input: false});

Via data attributes:

  <input type="file" class="filestyle" data-input="false">
启用或禁用输入文本。类型:Boolean,默认值:true
通过JavaScript:
$(“:file”).filestyle({input:false});
通过数据属性:
{input:false}
{disabled:true}


要使按钮看起来被禁用,请使用CSS

函数disableInput(e){$(“:file”).prop('disabled',true});}我以前确实使用过,但是该字段仍然没有“look”禁用。它在技术上可以完成工作,但外观保持不变,并且没有变灰。请尝试
$(“:file”).attr('disabled','disabled')也试过了,同样的事情发生了,被禁用了,但看起来不像。当我设置“{$(“:file”).prop('disabled',true});}”时发生了同样的情况。它将变为禁用,但不会变灰(看起来已禁用)。还有什么方法可以触发外观的改变吗?有点不需要使用引导文件样式。您只需使用jquery/Javascript更改disabled属性即可。尝试使用CSS设置禁用状态的样式
Enables or disables the input text. Type: Boolean, Default: true
Via JavaScript:

  $(":file").filestyle({input: false});

Via data attributes:

  <input type="file" class="filestyle" data-input="false">