Jump to content

Changing color multiple times


Recommended Posts

Hello!

i'd like to ask about this script

 

function farba(newcol) {    this.style.color = newcol;}function ahoj() {    var sup = document.getElementById('aaa');    farba.call(sup,'blue'); if(sup.style.color == "blue"){sup.style.color="red"}else{sup.style.color="blue"}

 

what should i change there for it , to work please?:)

Link to post
Share on other sites

Here's some demo code...

<!DOCTYPE html><html><head><meta charset="utf-8"><title>color</title><style>input{width:150px;height:50px;}</style><script>window.onerror = function(m, u, l){alert('Javascript Error: '+m+'nURL: '+u+'nLine Number: '+l);return true;}</script><script>window.onload = init;function init() {  document.getElementById('btn').onclick = ccc;}function ccc() {var c1 = this.style.color;if(c1 == "blue"){this.style.color="red";this.style.backgroundColor="blue";}else if(c1 == "red"){ this.style.color="green";this.style.backgroundColor="yellow";}else{this.style.color="blue";this.style.backgroundColor="red";}changebody(c1);}function changebody(pcolor){document.getElementById('b1').style.backgroundColor = pcolor;}</script></head><body id="b1"><input type="button" id="btn" value="Color Changer"/></body>    </html>
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...