jquery - CSS Transitions On/Off on Click -


http://codepen.io/dylanespey/pen/cvwzo

the goal animation play on click, , reverse on second click. i'm not sure how use javascript set (just learning it, see.). had idea add class using jquery, below, wasn't working. tried "cheat" using :target selector, that's not functional. ideas?

$(document).ready(function (){         $(function () {           $("#button").click(function () {               $("#button").toggleclass(".active");           });       });   }); 

http://codepen.io/anon/pen/qbgae

markup:

<body>     <ul>         <li>             <a href="#button">                 <div id="button">                     <div class="plus">+</div>                 </div>             </a>         </li>         <li>             <div id="banner">                 <p>some text viewing pleasure!</p>             </div>         </li>     </ul> </body> 

css:

.active {         color: red !important;     } 

script:

$(document).ready(function (){         $("#button").click(function () {               $(this).toggleclass("active");           });   }); 

you needed drop . .active in toggleclass.

secondly, didn't have active class in fiddle above, i'm guessing knew that.

good luck app.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -