Simple javascript can't figure out where it's wrong -
i can't figure out went wrong simple javascript
<!doctype html> <html> <head> <title> </title> <script> function changecolor() { var elem = document.getelementbyid("para1"); if (elem.style.color == black) { elem.style.color = blue } else if (elem.style.color == blue) { elem.style.color = red } else if (elem.style.color == red) { elem.style.color = black } } </script> </head> <body> <p id="para1"> text here</p> <button onclick='changecolor();'>change!</button> <!-- <button onclick='changecolor("red");'>red</button> --> </body> </html>
realise debugging harder javascript vba - i'm used it.
you're missing quotes around color values.
elem.style.color = 'red';
Comments
Post a Comment