how to change the color using js

<!DOCTYPE html>
<html>
<head>
<script>
function display()
{
var col=document.getElementById("demo");
col.style.color="#FF0000";
}
</script>
</head>
<body>

<h1>My First JavaScript</h1>
<p id="demo">click on the button below.....</p>

<button onclick="display()">Display</button>

</body>
</html>

4.2
5

                                    &lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;
&lt;title&gt;Change the Background Color with JavaScript&lt;/title&gt;
&lt;script&gt;
    // Function to change webpage background color
    function changeBodyBg(color){
        document.body.style.background = color;
    }
    
    // Function to change heading background color
    function changeHeadingBg(color){
        document.getElementById(&quot;heading&quot;).style.background = color;
    }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1 id=&quot;heading&quot;&gt;This is a heading&lt;/h1&gt;
    &lt;p&gt;This is a paragraph of text.&lt;/p&gt;
    &lt;hr&gt;
    &lt;div&gt;
        &lt;label&gt;Change Webpage Background To:&lt;/label&gt;
        &lt;button type=&quot;button&quot; onclick=&quot;changeBodyBg('yellow');&quot;&gt;Yellow&lt;/button&gt;
        &lt;button type=&quot;button&quot; onclick=&quot;changeBodyBg('lime');&quot;&gt;Lime&lt;/button&gt;
        &lt;button type=&quot;button&quot; onclick=&quot;changeBodyBg('orange');&quot;&gt;Orange&lt;/button&gt;
    &lt;/div&gt;
    &lt;br&gt;
    &lt;div&gt;
        &lt;label&gt;Change Heading Background To:&lt;/label&gt;
        &lt;button type=&quot;button&quot; onclick=&quot;changeHeadingBg('red');&quot;&gt;Red&lt;/button&gt;
        &lt;button type=&quot;button&quot; onclick=&quot;changeHeadingBg('green');&quot;&gt;Green&lt;/button&gt;
        &lt;button type=&quot;button&quot; onclick=&quot;changeHeadingBg('blue');&quot;&gt;Blue&lt;/button&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

4.2 (5 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
html javascript change color javascript change the color of an element using javascript to change color chnage color element js colour change code in js how to change a color in javascript javascript chane color change textcolor js js or css change colour java script change color of text javascript to change color css how to change color in javascript js set color change text color in javascript style color in js make text change color js javascript use style to change color custom color from js to css change color variable js js change color of text javascript function to change text color how to change page color in js change color using javascript dom changing color using javascript change color primary javascript change color via javascript js change html color css color in javascript alter color with javascri[t change document color in js js get css color how to change color via javascript javascript value color change finding style color value javascript change html i colorn js change color on text change javascript use css to change javascritpt colour function to change color in js change css color javascript text color change with js js give new color set color with javascript how to change color in javascript function change javascript color using css changing color js how to get html element value in javascript and change color change text and color js js change color style changing html color in javascript set color element javascript javascript change color text js function to modify css color css style color js change the color of element in js how to change text color javascript change element color js how to change color using js color changer js set color in js change color code by js function color change js css html how to change text color of page using javascript javascript color changing javascript create color according to value css change color with javaScript how to set color using javascript setting element color js js get css color as javascript set color java script how to make changing color teaxt color a on using javascript change page color js change element colour from js how to change the color in js DOM change color of element in javascript is a color value javascript what is a color value javascript change color of a tag in js change css font color with javascript using javascript to change the color of html change color javascript css js color css change color from css javascript javascript with red color add css atrr color using javascript JavaScript style change color how to change color of a text in javascript how to change text color in javascript document javascript change color change text color using this in javascript css in js colors.js javascript changing color f javascript changing color javascript how to change color of tex change html element color javascript new color javascript how to use style.color js how to change the color of an element with css javascript change colour dom in js change color function js how t0 change text color in javascript get css color in js change css color using javascript changing color in js javascript change color of text set color from javascript Howto change color of text using javascript how to get color javascript chn&aacute;nge color javascript change text to color js setcolor syntax javascript change color using dom js how to change css style color with javascript colorize colors in javascript javascript change colour text chnge color in js with this js get css elements and change color change elements colours javascript javascript change text color how to change color of css in js change color by javascript how to change text color js how to change color of element with javascript javascript change CSS style color javascript change color; how to pass color from javascript to css change color using javsascipt change colour js javascitp set color method change an element color with javascript javascript change css color how to save a color in javascript js change css color change text color javascript changing color through js change color css js set color js how to change color to text using js color change in js how to change the color of a style in javascript how to add color using javascript javascript altert color javascript change css text color how to change text color using javascript how to change the color of text in html by javascript js chaning colors css change color javascript js color set value bosy color change in javascript change color on value from javascript js change colour changing color on javascript in css set element color javascript change text color js change color css with javascript change colour javascript chnge color with javascript how to change color of html element using js javascript color change how to change css color using js set value of color on javascript js add style color change color from JS set color using javascript change color oinj js how to change colors in css using javascript js css style color javascrpit change color text change css color with javascript set color javascript css js change color css color in js javascript html change color Java script Color change js how to change color how to set color using js js css color how to change the text color in js how to change the color of text by js Set Color HTML CSS Javascript Set Colors HTML CSS Javascript how to change color in html using javascript changing the color of elements JS js change text color set elements color js javascript change style color change text colour javascript how to change color chanel in JS change css element using js getelementbyid().style.color changing css color with js how to change css style in javascript set color in javascript how to change css in javascript can you change css with javascript how to change color of background on document.write javascript how to change the background of document.write change css elements javascript how to apply colour in js change background color of body based on page how to change color on js all color change html js modify color javascript js color change change color through javascript change object color javascript &lt;button type=&quot;button&quot; onclick=&quot;changeHeadingBg('green');&quot;&gt;Blue&lt;/button&gt; js element style color SET DIV STYLE IN FUNCTION change element color in javascript with this change element color in javascript change color using js file javascript button change css how to change css style from javascript how to change colors in js colorchange by id in javascript colorchange in javascript js code for controling css explain window object of javascript dom.write a javascript code to change the background color webpage automatically after every 5 seconds change element color with javascript howt to change color of element with button css html js how to change style of the element by clicking document.getElementById(&quot;&quot;).style.color = how to change color inside a function change color of elemet using javascorpt xhtml and javascript code for dynamically changing background and foreground color using onchange event js change all p colors document.getelementbyid.style.color styleColor javascript bootstrap change background color of page on click event using javasceipt to change css how to change the color of a paragraph in javascript js style color how tu change color with js change color style javascript style.color in javascript how to change text color of css in javascript how to change color javascript change color by java scribt how to change color with java script how to change color of a tag in html using javascript add css value with js javascript on click change css change color of element js chabge color with javascript change color html javascript js document change color by id change color dom javascript set element by id color dom color style color javascript how to make color changer in js change color java script change color with id js how to change color in dom how to change color of element js change style with javascript onclick change color of an element javascript implement javascript in css how to change color of elemnt in js partcile js change color change color of html page in javascript how to change element color in javascript how to change color of html using js javascript color change code change colors javascript javascript change css syntax dom style text color Write a function that changes the background colour in html when the next and previous buttons are clicked The changes should be order . Write a function that changes the background colour in html when the next and previous buttons are clicked The changes should be order . Write a function that changes the background colour in html. The changes should be order . Write a function that changes the background colour in order . how to change css by javascript how to use the style.colot in javascript how can i change text color in js js change element color change javascript color how to change text color in js change color of an item using javascript dom change color css how to change color in js change css selector javascript javascript functions dom change color change position how to change the color of variables in javascript how to make an element change color in javascript keep changing color javascript add style via java script modify css property javascript change style color in js javascript modify color change color using dom change colors with javascript change color based of js how to change color of all element in javascript change color in js how to change div background color dynamically using javascript change color with style js change color in dom how can i change color in js javascript style set color change web page background color js javascript to change a sentence color website js change css of element change color of element in js change the color of a tag using js document change color with js change page background color css script how to change color of an element in javascript javascript style cilor replace css with javascript js function that changes the background colours of the theme css() in javascript dom setcolor change color of h1 using javascript how to change css property in javascript css function in javascript css style color javascript javascript function change color to html how to change color in dom html changing text color through dom dom change color document.getelementbyid change color javascript getelementbyid p color how to modify css property with javascript write css in javascript event color html css js js user change color js function change color change color by js how to change color in dom manipulation change the color of an element javascript why can i no t change css with javscript create a page that changes color when clicked change element by id color js style.color add color on an html element javascript how to change color ofo body using js w3schools how to use dom manipulation in js to changeont color how to change css how to manipulate style in dom js document.style.color change color using javascript change color intractively using javascript java script change color hytml back ground change script js stlyle color how to span change background color based on button javascript how to change background and text color in js js set backround style chanche background color function js how to use dom to change color javascript chnage css property document.getelementbyid change text color changing background color of node javascript js set element stype color change color element javascript accessing css from js function(element) javascript change css in javascript how do you change color how to add css in javascript how to change colors in javascript change the color in javascript javascript set background color of field to orange get css property from button javascript apply css to html using javascript change background color javascript project set an element's CSS with JavaScript changing color with javascript how to set color of element using javascript style color js how to change color of an id element in html css add background js change style in css javascript color css js change color of element how to change a background color in javascript javascript have css color how to change style with js change color of object javascript change element color javascript how to edit css with javascript background styke change javascript html dom css style change background javascipt how to change style color in javascript edit a color with javascript new style background in js add css style to html using javascript document get element by id change css how to change background colour of html with js change background color on javascript how to style color change with css how to make javascript change the color of background add backgeound color to text using javascript how to change and elements color in js javascript get element by id style color color in javascript select a tag and change background color in js change image background color javascript dom css color page set backgroundcolor nativescript change style of css with javascript style background with javascript change background javascript &lt;script&gt; change background javascript php change css property value in javascript how to add css style in javascript using css javascript write javascript to change css style javascript change color of paragraph how to change color of an element using javascript backgrounds using javascrip background change javascript build color change in css and javascript write css code in javascript set css style with js css function javascript javascript how to change the background color how to set backgroun in js modify css into js chnage css js change background color as time changes javascript how to change h1 tag color in javascript chag color javasc javascript code to get background color changed as y gives yellow javascript change color of element change an element colour via javascript add css from id in js how to change the color property of an html element in javascript change color using js call css in javascript how to call css from javascript html javascript background color change style.color js javascript alter style javascript css manipulation HOw to change the color of code in javascript how to edit css in javascript changing style through javascript change hte fcolor of somthing using js css chang style with js color change javascript javascript switch background color changing css style with javascript how to change background of html javascript css javascript apply style to element javascript accessing css javascript change background color with prompt how to set css using js How to change the color of a background in js change section color javascript call css style in js js change property css js change color css js edit styling how to change javascript css javascript dom style manipulation font colour changing color in html/css element.style change css in javascript how to change css with javascript how to change style with javascript change css property on click javascript how to change background color of body change elements color with javascript can we chage css from js how to access css with javascript how to change title background color in javascript javascript change element color update css with javascript js assign color js changre css how to change color by javascript change css property via js javascript how to change color css using javascript change color in javascript edit css via js how to change color of element in javascript edit css file with javascript how to change css elements with javascript javascript css function change color of this javascript change background color using javascript function change color of the site js css how to change on JS function javascript how to change html color js modify color js apply css javascript set style color change the style using javascript javascript how to change css style javascript edit css change the css using javascript change ::before background color property javascript change before background color property javascript how to fill in color webpage javascript javascript change colors color change js color style javascript how to change color using javascript getelementbyid css color javascript on css change change style by id javascript change background color of image using javascript set element style color javascript how to change a css property with javascript how to style background color javascript how to change colors javascript changing colors in javascript how to change value to css property in javascript change color from javascript how to get elements css color in js js change css property how to change css using javascript changing style using javascript change css using javascript changing a css property with javascript javascript change css value change style from javascript .style.color javascript change color javascript css code in js a color property in js change all element colros in javascript how to change color in javascript how to change color in javas how to change styles using js css change javascript html change css from js javascript how to change css properties html change color with js javascript change color style chaging using js element.style.color color css js change css with javascript call css javascript change css property javascript how to change :after in css using javascript javascript style color change color js css change background with javascript program to change background in javascript how to change color with javascript change body background colour js how to change a css property in js javascript - style.color change color dom javascript change color jvscript javascript to change colors The background colour of the HTML page will change based on the link which is clicked. Write a javascript function to implement it. js change color css in javascript changing css using javascript javascript change css style.color in java script change color of element javascript how to change css attribute javascript $ how to change css attribute javascript changing style in javascript change page background colour js change color with javascript javascript change colour write css with js script to add css property how to get css color property value using javascript how to change style using javascript adding css through js display how to alter css using javascript change css of html element in javascript add css by javascript change css property using javascript javascript interact with css how to change placeholder color using javascript how to add color gradient in p5 js how to change color css color gradient in p5 js rgb color from jquery css change a color css how to modify the browser window color using javascript changing color by javascript changing color in javascript javascript set css color change the background using css javascript color change using js how to change the color using js how to change background color of p tag in javascript function color changing using javascirpt javascript function to change color over time change color javascript code change background color css using js swap colors using javascript swap colour using javascript change colour of element javascript javascript function color change set background color of class in javascript
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source