This project has moved and is read-only. For the latest updates, please go here.

Conflics with $(".ms-formtable td) operation

Oct 29, 2015 at 9:54 PM
Edited Oct 29, 2015 at 9:55 PM
I have an edit form where I am changing the font color and style of the Description of the fields using the below code:

$(".ms-formtable td").css({"color":"Navy", "font-weight":"normal", "font-style":"normal", "font-size":"13px"});

[unfortunately, this also applies the style to my field values which I have made read only using .MakeReadOnly() call, which I don't want as I don't have any description attached to the these fields I am making read only.

Any help you could provide? Thanks in advance.!
Nov 1, 2015 at 11:59 PM
Edited Nov 1, 2015 at 11:59 PM
Yep, I can see what you mean. Since the read-only text is put inside the same control it is getting the style as well.

You have a couple options.

Option 1: All SPUtility read-only div's get the .sputility-readonly class applied. This means you could add another selector to change them back to what you want:
$(".sputility-readonly").css({"color":"Black", "font-weight":"normal", "font-style":"normal", "font-size":"13px"});

Option 2: Narrow your original selector to only find the description fields:
$(".ms-formtable td").css({"color":"Blue", "font-weight":"normal", "font-style":"normal", "font-size":"20px"});

Hopefully this helps. Thanks,
Nov 3, 2015 at 9:27 PM
Many Thanks Kit,

Both options works just perfectly. However I went with Option 1 as I have numerous fields on my form that gets different css on metadata.

Thanks again.