Note that there are some explanatory texts on larger screens.

plurals
  1. POcolor picker code
    primarykey
    data
    text
    <p>I have this code to change the color of elements like the Background-color,text color,active link color,visited link color etc. inside a div. I have to enter the color for each in the text-boxes and accordingly the color of background,text color,link colors would change. This is the program objective. But I can't change the colors of the active, followed and visited links. How to do that with only HTML, CSS and JavaScript? Please don't tell me any method using jQuery, as I don't know jQuery. I only want it it with JavaScript.</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;script&gt; function fun() { var bg=document.getElementById("t1").value; var txt=document.getElementById("t2").value; var al=document.getElementById("t3").value; var vl=document.getElementById("t4").value; var hv=document.getElementById("t5").value; document.getElementById("dv").style.backgroundColor=bg; document.getElementById("dv").style.alinkcolor=txt; document.getElementById("dv").style.vlinkcolor=al; document.getElementById("dv").style.color=vl; document.getElementById("dv").style.color=hv; } &lt;/script&gt; &lt;h1&gt;Enter Colors: &lt;/h1&gt; Background: &lt;input type="text" id="t1" name="txt1"&gt; &lt;br/&gt;&lt;br/&gt; Text: &lt;input type="text" id="t2" name="txt2"&gt; &lt;br/&gt;&lt;br/&gt; Link: &lt;input type="text" id="t3" name="link"&gt; &lt;br/&gt;&lt;br/&gt; Active Link: &lt;input type="text" id="t4" name="alink"&gt; &lt;br/&gt;&lt;br/&gt; Followed Link: &lt;input type="text" id="t5" name="vlink"&gt; &lt;br/&gt;&lt;br/&gt; &lt;input type="button" value="test" onclick="fun();"&gt; &lt;br/&gt;&lt;br/&gt; &lt;div id="dv"&gt;&amp;nbsp;hello This is a Test&lt;br/&gt; You Have Selected These Colors&lt;br/&gt; &lt;a href="#"&gt;This is a Test Link&lt;/a&gt;&lt;br/&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload