Javascript examples for CSS Style Property:background
Check element background value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from w w w . j a va2s.co m var foo = document.getElementById("foo"); foo.onclick = function(){ if(foo.style.background!="yellow") foo.style.background = "yellow"; else if(foo.style.background =="yellow") foo.style.background = "pink"; }; }); </script> </head> <body> <p id="foo">Hello, people!</p> </body> </html>