function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sam CousinsSam Cousins 

How to change text color of pageMessage with Javascript?

Hi All,

I have the following javascript: 
 
document.getElementById("{!$Component.f.pageBlock3.pageMessage3}").TextContent.Style.Color = "Red";

How would I change the color of this element? The above doesn't seem to work. If I do

 
Gyanender SinghGyanender Singh
Hi Sam,

I think your syntax is not right. Please you this. 
document.getElementById('{!$Component.f.pageBlock3.pageMessage3}').style.color = 'blue';

 
Gyanender SinghGyanender Singh
Hi Sam,

If you want to show your error messange in the styling style and if your using eg "ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.')"  this type of page message in your class so in place of pagemessage use Output Panel and reRender the output panel on the msg id  and hide the output panel in starting.