tags:

views:

30

answers:

3

I need to be able to apply css styles to all elements that are/become disabled

$(document).ready(function() {
  $("input type:checkbox").attr("disabled", true).css("border","1px solid #000000");
});

doesn't seem to work. any ideas?

+1  A: 

Try :checkbox and :disabled selectors

$(document).ready(function() { 
  $("input:checkbox:disabled").css("border","1px solid #000000"); 
}); 

Also it would be better if you add a class for that instead of applying css directly. Something like

.disabledcheckbx { border: 1px solid #000; }

and then

$(document).ready(function() { 
  $("input:checkbox:disabled").addClass("disabledcheckbx");
}); 
rahul
Also, this will automatically apply to any checkboxes that become disabled as your page works, thus it fully answers the question.
BoltClock
A: 

That will attempt to set every checkbox's disabled attribute to true.

You want this:

$(document).ready(function() {
  $(':checkbox:disabled').css('border', '1px solid #000;');
});
Dave Ward
A: 

styling checkboxes is not widely supported by most browser as you can see in this test.

but if you really want it, you may try this plugin

Reigel