为输入类型文件按钮添加禁用样式(css)
Add disabled style (css) to input type file button
我禁用了JQuery中的输入文件按钮
$('#ID').attr('disabled', true)
但是,按钮看起来仍然是启用的,不显示禁用的样式(灰色)
我试过改变CSS
// Example
$('#ID').css("background-color", 'yellow')
但是不管我放了什么css,按钮都不会改变样式。
我能做什么?
我正在使用的对象(HTML)
<input type="file" id="ID" class="" name="files[]" multiple />
谢谢
抱歉之前的回答。
我建议你检查这个链接,以了解更改input file
样式的可能性。
div.fileinputs {
position: relative;
}
div.fakefile {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
<div class="fileinputs">
<input type="file" class="file" disabled/>
<div class="fakefile">
<input disabled/>
<img src="http://fptp.uthm.edu.my/mba/images/911c660826c0b.png" style="width:30px;"/>
</div>
</div>
可以用disabled
代替true;
$("#ID").attr('disabled','disabled');
或者你可以使用。prop()
$("#ID").prop('disabled', true);
$("#ID").prop('disabled', false);
使用prop代替attr:
$("#id").prop("disabled",true);
https://jsfiddle.net/8fvga3xk/8/你可以使用CSS选择器:disabledhttp://www.w3schools.com/cssref/sel_disabled.asp
.yourButtonClass:disabled{
background-color:#dddddd;
}
相关文章:
- 如果文本字段为空,则使用JavaScript应用CSS样式
- FF和Chromium中CSS样式按钮的外观差异
- CSS样式属性留空
- 使用javascript单击同一按钮,在两种样式之间更改css值
- 用CSS在CKEditor中设置预览样式
- Javascript+动态菜单+当前链接样式(CSS)+基于PHP的网站
- 如何使用jQuery转换所有带有动态类的内联样式css
- iFrame 中的实时预览和保存样式.css每 30 秒一次
- 如何更改 jquery UI 数据选择器的样式 (CSS)
- 在Javascript中设置左样式CSS属性以移动滑块
- css+jQuery样式.css切换器,用于新的jQuery版本
- Chrome 29样式/Css问题
- 如何更改工具提示的样式/css
- 字体Awesome与半样式CSS
- Angular2组件样式/css没有被浏览器应用在ngafterviewit中
- 如何改变网页内容,而不删除任何样式/css/图形
- 使用Javascript在不影响打印样式的情况下更改显示样式(CSS)
- 使用 Get Time Javascript 更改样式 CSS
- 自定义下拉列表样式(CSS/JS与ASP.. NET c#连接)
- 为输入类型文件按钮添加禁用样式(css)