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
Srinu@dreamsSrinu@dreams 

How to change color of a link from one color to another color?

In visualforce page, I have a link once I click on that link it should change from red color to green color, I am getting in html but it is not working in visualforce?

Best Answer chosen by Admin (Salesforce Developers) 
asish1989asish1989

Hi

   Will you check this and let me know...

<apex:form >
 <script type="text/javascript">  
            function turnRed(id) {
                 alert("hi");
                 var myPara = document.getElementById(id);
                 alert(myPara);
                 myPara.style.color = "green";
            }
        </script>
        <apex:pageBlock >
  <apex:commandLink  action="{!gogoogle}" target="_blank" value="Go Google"  id="check" style="color:red"  onclick="turnRed('{!$Component.check}')"/>

</apex:form>

 Did this post answers your problem ,If so please mark it solved so that other's get benifited

 

Thanks

asish

All Answers

bob_buzzardbob_buzzard

You'd usually do this through CSS styling.  The style in question is 'a:visited',  e.g.

 

<style>
a:link {background: #FFCC00; text-decoration: none}
a:visited {background: #FFCC00; text-decoration: none}
a:active {background: #FFCC00; text-decoration: none}
a:hover {background: #FFCC00; font-weight:bold; color: red;}
</style>

 

asish1989asish1989

Hi

   Will you check this and let me know...

<apex:form >
 <script type="text/javascript">  
            function turnRed(id) {
                 alert("hi");
                 var myPara = document.getElementById(id);
                 alert(myPara);
                 myPara.style.color = "green";
            }
        </script>
        <apex:pageBlock >
  <apex:commandLink  action="{!gogoogle}" target="_blank" value="Go Google"  id="check" style="color:red"  onclick="turnRed('{!$Component.check}')"/>

</apex:form>

 Did this post answers your problem ,If so please mark it solved so that other's get benifited

 

Thanks

asish

This was selected as the best answer