Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textarea readonly but change background color back to white

Tags:

html

jquery

css

I am trying to make a textarea readonly but do not like the gray background and want to make it white again... Is this possible because everything I am trying fails and it stays gray.

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;
}
like image 734
Vicki Avatar asked Oct 22 '15 17:10

Vicki


2 Answers

Use !important in your rule in order to override the browsers default value:

.input-disabled{
    background-color:#FFF !important;
}

FIDDLE

like image 193
taxicala Avatar answered Oct 09 '22 22:10

taxicala


Try this http://jsfiddle.net/ma42koz3/2/

CSS

.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
   background-color: white;
}

EDIT:

You can add class for example no-grayon textarea you don't want to be gray http://jsfiddle.net/ma42koz3/4/ and use this

CSS

.form-control[readonly].no-gray {
  background-color:white;
}

HTML

<textarea type="text" name="DueToday" id="DueToday" class="form-control no-gray" rows="7"></textarea>
like image 22
Nenad Vracar Avatar answered Oct 09 '22 20:10

Nenad Vracar