我试图做一个textarea readonly但不喜欢灰色背景,并希望再次变白…这是可能的,因为我尝试的一切都失败了,它保持灰色. http://jsfiddle.net/ma42koz3/ HTML div class="col-xs-6" div class="row" div id="DToday
http://jsfiddle.net/ma42koz3/
HTML
<div class="col-xs-6"> <div class="row"> <div id="DToday" class="col-xs-12"> <label class="centered" for="DueToday">DUE TODAY @ 5:00</label> <textarea type="text" name="DueToday" id="DueToday" class="form-control" rows="7"></textarea> </div> <div id="DTmrw" class="col-xs-12"> <label class="centered" for="DueTmrw">DUE <span id="delivery-date"></span> @ 5:00</label> <textarea type="text" name="DueTmrw" id="DueTmrw" class="form-control" rows="7"></textarea> </div> </div> </div>
JS
$(document).ready(function() { $('#DueToday').attr('readonly', true); $('#DueToday').addClass('input-disabled'); $('#DueTmrw').attr('readonly', true); $('#DueTmrw').addClass('input-disabled'); });
CSS
.input-disabled{ background-color:#FFF; }在规则中使用!important以覆盖浏览器的默认值:
.input-disabled{ background-color:#FFF !important; }
FIDDLE