1

I used the CSS here:

@keyframes themesappear{
    0% {
        opacity: 0;
    } 100% {
        opacity: 1;
    }
}
@-webkit-keyframes themesappear{
    0% {
        opacity: 0;
    } 100% {
        opacity: 1;
    }
}

and the Javascript here:

var theme = function() {
    document.getElementById('themes').style.animation = "themesMappear 2s forwards;";
    document.getElementById('themes').style.WebkitAnimation = "themesappear 2s forwards;";
};

in attempt to make the div with the id "themes" fade in and appear...

The problem is the onclick does not work, and neither does the opacity change, how can I fix this? You can see the website here

How I used the onlclick: <h1 id = "WM" onclick = "theme()">Change Theme</h1>

1
  • 1
    Can you show how you are using the onclick? Commented Jun 4, 2015 at 21:02

1 Answer 1

5

few things

  1. you seem to have a typo (themesMappear instead of themesappear)
  2. you have a semicolon at the end of the rule, which makes it invalid and therefore not added. It should be "themesMappear 2s forwards", not "themesMappear 2s forwards;"
  3. you should really create a class with those rules, and then just toggle the class with those styles via JS
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Any idea why the onclick isn't triggering?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.